明显是无良心的数学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. centos6.5 安装

    导系统,进入rescue模式,在提示符下输入grub,进入grub提示符.(不管用什么方法,能进入grub就行)root(hd?,?) //前一个问号是你第几块硬盘,后一个是LINUX所在的第几个分区 ...

  2. JavaScript Math对象

    Math对象是JavaScript的一个固有对象,其作用是执行常见的算数任务.该对象的使用并不是像Date,Array对象使用 new关键字来得到对象,而是直接 Math.[{property|met ...

  3. Unity3D 相机跟随主角移动

    这里给主相机绑定一个脚本. 脚本写为: using UnityEngine; using System.Collections; public class camerafollow : MonoBeh ...

  4. Linux gvim windows 版本配置

    http://www.cnblogs.com/xiekeli/archive/2012/08/13/2637176.html 资源在我的网盘里面

  5. 发布MVC IIS 报错未能加载文件或程序集“System.Web.Http.WebHost

    未能加载文件或程序集“System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e3 ...

  6. php函数serialize()与unserialize()

    serialize()和unserialize()在php手册上的解释是: serialize — Generates a storable representation of a value ser ...

  7. IIViewDeckController的使用,左右拖拉菜单效果实现

    博客园   IIViewDeckController的使用,左右拖拉菜单效果实现   很多应用里面都实现了对应的侧拉 显示隐藏的效果,看起来很符合用户体验的类似于这种   看起来很好看,今天去晚上搜下 ...

  8. ueditor爬坑

    在使用UeEditor中遇到几个个坑 1.添加的html代码中使用的样式class被guolv掉 解决方案:在ueditor.config.js中,xss过滤白名单中,每个元素添加class,如下图 ...

  9. C#遍历窗体控件(原文出自http://www.liangshunet.com/ca/201403/286434593.htm)

    一.C#遍历窗体控件 主要遍历属于窗体(Form)的控件(Controls),假如窗体中有 Panel.Button 和 TextBox 控件,遍历代码如下: /// <summary> ...

  10. java中如何操作数据库(增删改查)

    EntityManager 是用来对实体Bean 进行操作的辅助类.他可以用来产生/删除持久化的实体Bean,通过主键查找实体bean,也可以通过EJB3 QL 语言查找满足条件的实体Bean.实体B ...