明显是无良心的数学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)的更多相关文章

  1. 判素数+找规律 BestCoder Round #51 (div.2) 1001 Zball in Tina Town

    题目传送门 /* 题意: 求(n-1)! mod n 数论:没啥意思,打个表能发现规律,但坑点是4时要特判! */ /***************************************** ...

  2. hdu 5636 搜索 BestCoder Round #74 (div.2)

    Shortest Path  Accepts: 40  Submissions: 610  Time Limit: 4000/2000 MS (Java/Others)  Memory Limit: ...

  3. 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 ( ...

  4. 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 ...

  5. BestCoder Round #11 (Div. 2) 题解

    HDOJ5054 Alice and Bob Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  6. hdu5635 BestCoder Round #74 (div.2)

    LCP Array  Accepts: 131  Submissions: 1352  Time Limit: 4000/2000 MS (Java/Others)  Memory Limit: 13 ...

  7. hdu5634 BestCoder Round #73 (div.1)

    Rikka with Phi  Accepts: 5  Submissions: 66  Time Limit: 16000/8000 MS (Java/Others)  Memory Limit: ...

  8. hdu5631 BestCoder Round #73 (div.2)

    Rikka with Graph  Accepts: 123  Submissions: 525  Time Limit: 2000/1000 MS (Java/Others)  Memory Lim ...

  9. hdu5630 BestCoder Round #73 (div.2)

    Rikka with Chess  Accepts: 393  Submissions: 548  Time Limit: 2000/1000 MS (Java/Others)  Memory Lim ...

随机推荐

  1. shell入门之函数应用 分类: 学习笔记 linux ubuntu 2015-07-10 21:48 77人阅读 评论(0) 收藏

    最近在学习shell编程,文中若有错误的地方还望各位批评指正. 先来看一个简单的求和函数 #!/bin/bash #a test about function f_sum 7 8 function f ...

  2. css 实现页面加载中等待效果

    <!DOCTYPE html> <html> <head> <title>css实现页面加载中,请稍候效果</title> <meta ...

  3. spring事务回滚无法捕捉

    这篇文章讲解了怎么配置才能让spring事务捕捉异常 http://www.360doc.com/content/12/1109/18/6161903_246870991.shtml 需要正确配置sp ...

  4. ubuntu JDK

    第一步:下载jdk-7-linux-i586.tar.gz 第二步:解压安装 cd /usr/libsudo mkdir jvm cd {你的目录jdk压缩文件目录} sudo tar zxvf jd ...

  5. Servlet(三)

    重定向 服务器向浏览器发送一个302状态码以及一个Location消息头(该消息头的值是一个地址,称之为重定向地址),浏览器收到后会立即向重定向的地址发出请求,使用相应对象的API方法实现(respo ...

  6. java的动态绑定与双分派(规避instanceof)

    1. 动态绑定的概念 指程执行期间(而不是在编译期间)判断所引用对象的实际类型,根据其实际的类型调用其相应的方法 . 例如: package org.demo.clone.demo; public c ...

  7. [转]iframe自适应宽度高度

    <iframe id="iframe" onLoad="AutoFit();" frameborder="0" scrolling=& ...

  8. 在easyui dialog的子页面内如何关闭弹窗

    因项目需要在dialog中添加滚动条,所以就在div中加了iframe: <div id="applyRefundDialog" style="display:no ...

  9. Android 动画效果 及 自定义动画

    1. View动画-透明动画效果2. View动画-旋转动画效果3. View动画-移动动画效果4. View动画-缩放动画效果5. View动画-动画效果混合6. View动画-动画效果侦听7. 自 ...

  10. 一些CMS网站系统漏洞,练手用(持续更新)

    仅供拿shell,提权测试用,请勿恶意破坏 XuSoft系统: 后台万能密码:'or'='or'  可直接登陆,后台地址 /manage/login.asp inurl:ReadArticlemb.a ...