zoukankan      html  css  js  c++  java
  • Codeforces_492_E

    http://codeforces.com/problemset/problem/492/E

    题目规定了gcd=1,可以在纸上模拟一下,发现每一个起点,都会经历过n个点,n个点都是不同行不同列。可以把这n个点归为一组,一共n组。

    我们按照纵坐标来编号,然后求出每一组的数量就可以得出答案了。

    #include<iostream>
    #include<cstring>
    #include<cstdio>
    #include<algorithm>
    #define MAX 1000005
    using namespace std;
    
    int n,m,dx,dy,a[MAX],ans[MAX];
    
    int main()
    {
        scanf("%d%d%d%d",&n,&m,&dx,&dy);
        int x = 0,y = 0;
        for(int i = 1;i <= n;i++)
        {
            a[x] = y;
            x = (x+dx)%n;
            y = (y+dy)%n;
        }
        int maxa = 0,maxy = 0;
        for(int i = 1;i <= m;i++)
        {
            scanf("%d%d",&x,&y);
            int temp = y-a[x];
            if(temp < 0)    temp += n;
            ans[temp]++;
            if(ans[temp] > maxa)
            {
                maxa = ans[temp];
                maxy = temp;
            }
        }
        printf("0 %d
    ",maxy);
        return 0;
    }
  • 相关阅读:
    eclipse使用svn
    yum安装mysql
    spring中aop使用
    mybatis定义拦截器
    横扫页面的三大标签
    springmvc日期格式化
    springmvc笔记
    springboot跳转jsp页面
    常用网址
    CentOS Android Studio桌面图标的创建
  • 原文地址:https://www.cnblogs.com/zhurb/p/5946672.html
Copyright © 2011-2022 走看看