BestCoder Round #51 (div.2)
明显是无良心的数学round= =
1000 Zball in Tina Town
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<cstring>
#define PAU putchar(' ')
#define ENT putchar('\n')
#define Safe 6
using namespace std;
typedef long long LL;
const int maxn=+;
LL gcd(LL a, LL b){
return b == ? a : gcd(b, a % b);
}
LL n, x, mx;
LL mul(LL a, LL b, LL p){
LL tmp = (a * b - (LL)((long double)a / p * b + 1e-) * p);
return tmp < ? tmp + p : tmp;
}
LL pow(LL a, LL b, LL p){
LL ans = ; a %= p;
for(LL i = b; i; i >>= , a = mul(a, a, p))
if(i & ) ans = mul(ans, a, p);
return ans;
}
bool check(LL a, LL n, LL r, LL s){
LL ans = pow(a, r, n), p = ans;
for(int i = ; i <= s; i ++){
ans = mul(ans, ans, n);
if(ans == && p != && p != n - ) return true;
p = ans;
}
if(ans != )return true;
return false;
}
bool MR(LL n){
if(n <= ) return false;
if(n == ) return true;
if(n % == ) return false;
LL r = n - , s = ;
while(r % == ) r /= , s ++;
for(int i = ; i < Safe; i ++)
if(check(rand() % (n - ) + , n, r, s)) return false;
return true;
}
inline LL read(){
LL x=;bool sig=;char ch=getchar();
for(;!isdigit(ch);ch=getchar())if(ch=='-')sig=;
for(;isdigit(ch);ch=getchar())x=*x+ch-'';
return sig?x:-x;
}
inline void write(LL x){
if(x==){putchar('');return;}if(x<)putchar('-'),x=-x;
int len=;static LL buf[];while(x)buf[len++]=x%,x/=;
for(int i=len-;i>=;i--)putchar(buf[i]+'');return;
}
int T;
int main(){
T=read();LL x;
while(T--){
x=read();
if(x==){write();ENT;continue;}
if(x==){write();ENT;continue;}
if(MR(x))write(x-),ENT;
else write(),ENT;
}
// for(LL x=1;x<=100;x++){
// LL fac=1;
// for(int i=2;i<x;i++)fac=fac*i%x;write(x);PAU;write(fac);ENT;
// }
return ;
}
然后这道题全场都被至少扣了一分,不明觉厉= =
1001 Infoplane in Tina Town

显然不可写= =div1都没有人过= =
BestCoder Round #51 (div.2)的更多相关文章
- 判素数+找规律 BestCoder Round #51 (div.2) 1001 Zball in Tina Town
题目传送门 /* 题意: 求(n-1)! mod n 数论:没啥意思,打个表能发现规律,但坑点是4时要特判! */ /***************************************** ...
- hdu 5636 搜索 BestCoder Round #74 (div.2)
Shortest Path Accepts: 40 Submissions: 610 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: ...
- BestCoder Round #69 (div.2) Baby Ming and Weight lifting(hdu 5610)
Baby Ming and Weight lifting Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K ( ...
- BestCoder Round #68 (div.2) tree(hdu 5606)
tree Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submis ...
- BestCoder Round #11 (Div. 2) 题解
HDOJ5054 Alice and Bob Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- hdu5635 BestCoder Round #74 (div.2)
LCP Array Accepts: 131 Submissions: 1352 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 13 ...
- hdu5634 BestCoder Round #73 (div.1)
Rikka with Phi Accepts: 5 Submissions: 66 Time Limit: 16000/8000 MS (Java/Others) Memory Limit: ...
- hdu5631 BestCoder Round #73 (div.2)
Rikka with Graph Accepts: 123 Submissions: 525 Time Limit: 2000/1000 MS (Java/Others) Memory Lim ...
- hdu5630 BestCoder Round #73 (div.2)
Rikka with Chess Accepts: 393 Submissions: 548 Time Limit: 2000/1000 MS (Java/Others) Memory Lim ...
随机推荐
- cocoaPods下载使用记录
cocoaPods下载使用记录 参考地址: 如何在Mac OS 上安装运行Ruby运行环境 http://www.cnblogs.com/daguo/p/4097263.html cocoaPods安 ...
- Bash函数使用
#!/bin/bash function Fun_Name() { #function here echo "this is a function" } Fun_Name
- NUll在oracle与sqlserver中使用相同与区别
最近在使用Oracle进行开发,遇到很多与以前使用sqlserver的不同语法.今天遇到null在两种数据库上面操作上的差别,在此记录两种数据库上的差异. null 与字符串相加 1.在oracle中 ...
- OpenGL ES 3.0 点,线,三角形绘制形式总结
OpenGL ES 3.0 顶点 -1, 1, 0, -0.5f, 0, 0, 0, -1, 0, -1, 0, 0, 0.5f, 0, 0, 1, -1, ...
- C#调用百度云存储接口上传文件
因前几日见园子里有人说可以把网站静态文件放在百度上,于是去百度开放平台看了看,发现之前那篇文章不是调的云存储接口啊... 于是自己写了个C#能调百度云存储的例子(百度云开放平台只提供php.java. ...
- powerdesigner设置唯一键,但不是主键的方式
[转载]http://blog.csdn.net/cnham/article/details/6676650 唯一约束 唯一约束与创建唯一索引基本上是一回事,因为在创建唯一约束的时候,系统会创建对应的 ...
- java 从jar包中读取资源文件
在代码中读取一些资源文件(比如图片,音乐,文本等等),在集成环境(Eclipse)中运行的时候没有问题.但当打包成一个可执行的jar包(将资源文件一并打包)以后,这些资源文件找不到,如下代码: Jav ...
- javascript 之DOM篇
要怎么样的开场白才能使我有力气再更新学习进度呢?啊啊啊啊啊,表示好累啊~~~默念“棒棒棒,我最棒~”召唤精气神开总结敲字咯.哈哈哈. --------------------------------- ...
- Lua-C交互函数
lua_gettable(lua_State * , tableIndex) //获取表的在key位置的值 过程:tableIndex为表在栈的位置,例:-2为第二个位置 , 此时会弹(出)栈作为参数 ...
- 本大神教你用PHP把文本内容转换成16进制数字,进行加密
<?php $a="杨波"; $b = bin2hex($a); echo $a."<br />"; $c = pack("H*&q ...
