ural1682 Crazy Professor
Crazy Professor
Memory limit: 64 MB
- b + a · a ≡ 0 (mod k),
- a + b · b ≡ 0 (mod k),
where k is some parameter.
Input
Output
Sample
| input | output |
|---|---|
2 |
5 |
Notes
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=2e5+;
using namespace std;
ll gcd(ll p,ll q){return q==?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=;while(q){if(q&)f=f*p;p=p*p;q>>=;}return f;}
int n,m,k,t,p[maxn],now[maxn];
vi mo[maxn];
int find(int x)
{
return p[x]==x?x:p[x]=find(p[x]);
}
int main()
{
int i,j;
scanf("%d",&k);
rep(i,,maxn-)p[i]=i;
for(i=;;i++)
{
ll q=((ll)i*i/k+)*k;
while((j=q-(ll)i*i)<i)
{
int x=find(j),y=find(i);
if(x==y)return *printf("%d\n",i);
else p[x]=y;
now[j]=i;
q+=k;
}
q=(ll)(i/k+)*k;
for(int x:mo[(q-i)%k])
{
if(now[x]==i)continue;
int y=find(x),r=find(i);
if(y==r)return *printf("%d\n",i);
else p[y]=r;
}
mo[(ll)i*i%k].pb(i);
}
//system("Pause");
return ;
}
ural1682 Crazy Professor的更多相关文章
- 1682. Crazy Professor(并查集)
1628 加了些数论知识 先看下剩余类的概念 一个整数被正整数n除后,余数有n种情形:0,1,2,3,…,n-1,它们彼此对模n不同余.这表明,每个整数恰与这n个整数中某一个对模n同余.这样一来,按 ...
- URAL 1682 Crazy Professor (并查集)
[题目链接] http://acm.timus.ru/problem.aspx?space=1&num=1682 [题目大意] 给出k,从1开始不断地加一并把这个数写在黑板上,如果写上的数字和 ...
- DevOps is dirty work - CI drives you crazy
一直很想谈谈Continuous Integration(CI),持续集成. 就在不久前一次朋友聚会上,一个刚刚跳槽到一家创业公司的朋友跟我抱怨说他们没有CI,没有code review,要做点事太累 ...
- Here's to the crazy ones.
Here's to the crazy ones. The misfits. The rebels. The troublemakers. The round pegs in the square h ...
- Urban Planning and Public Health - Reflection on Professor Webster's article in Urban Planning Forum
1. General review. Professor Webster published this article in Urban Planning Forum, one of the top ...
- [poj3378] Crazy Thairs (DP + 树状数组维护 + 高精度)
树状数组维护DP + 高精度 Description These days, Sempr is crazed on one problem named Crazy Thair. Given N (1 ...
- [poj1200]Crazy Search(hash)
Crazy Search Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 26713 Accepted: 7449 Descrip ...
- Light OJ 1393 Crazy Calendar (尼姆博弈)
C - Crazy Calendar Time Limit:4000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Su ...
- THE ARCHITECTURE OF COMPLEXITY HERBERT A. SIMON* Professor of Administration, Carnegie Institute of Technology (Read April 26, 1962)
THE ARCHITECTURE OF COMPLEXITY HERBERT A. SIMON* Professor of Administration, Carnegie Institute of ...
随机推荐
- Python 数据分析包:pandas 基础
pandas 是基于 Numpy 构建的含有更高级数据结构和工具的数据分析包 类似于 Numpy 的核心是 ndarray,pandas 也是围绕着 Series 和 DataFrame 两个核心数据 ...
- Network view
network view 组件用来在局域网之内去同步一个游戏物体的组件属性,只响应创建它的那个客户端事件
- EXCEL应用:高级筛选里的条件或和与的条件怎么写 例:不包含,包含等
============================================================= a列包含b列,在c列中显示b列信息, =INDEX(B:B,MIN(IF(I ...
- 初次使用IntelliJ IDEA 2016.2
换电脑的还有一个目的就是我准备采用新的IDE了 之前一直用的是myeclipse,但是现在准备尝试idea 这边做个记录,idea的破解参考下面这个网址:http://blog.csdn.net/u0 ...
- JavaScript高级程序设计:第二十一章
第二十一章 Ajax与Comet 一.XMLHttpRequest对象 1.XHT的用法 在使用XHR对象时,要调用的第一个方法时open( ),它接受3个参数:要发送的请求的类型.请求的URL和表示 ...
- Ubuntu14.04+cuda 7.5+cudnn_v4+tensorflow安装
系统环境:Ubuntu14.04 64位.Windows7 64位 双系统 CUDA 版本: 7.5 总结一下,我的安装建议是: 一定要下一份CUDA官方的安装文档,按照它的步骤一步步慢慢来,不可偷懒 ...
- MinGW 运行C++程序的方法
1:安装好 MinGW 及 GCC 编译器后 , 当然 MinGW 全安装最保险了,不会太费劲 2:配置环境变量(注:可能需要重启后生效) 计算机 --> 属性 --> 高级系统设置 -- ...
- nginx 安装三方包重新编译
sudo -sapt-get source nginxapt-get build-dep nginxwget 'https://github.com/agentzh/chunkin-nginx-mod ...
- shell命令一行代码搞定【转】
查看文件内容-while: cat 1.txt|while read line;do echo $line;done while read line; do echo $line; done < ...
- oomph
http://blog.csdn.net/u011004037/article/details/45679573 这么好个功能起了这么操蛋个名字害得老子一直不知道他干啥的