Codeforces Round #174 (Div. 2)
来源:互联网 发布:淘宝卖家采集器 编辑:程序博客网 时间:2024/06/04 19:39
A题 写麻烦了 直接乘 p-1次就可以 我还用快速幂 把1--p-1都求了出来 边求边取模
#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<stdlib.h>#include<cmath>using namespace std;int result(int a,int b,int m){ int d,t; d=1; t=a; while (b>0) { if (b%2==1) d=(d*t)%m; b/=2; t=(t*t)%m; } return d;}int main(){ int i,j,k,n,m,sum=0,flag = 1,s,g; cin>>n; for(i = 1; i < n ; i++) { flag =1; for(j = 1 ; j <= n-2 ; j++) { s = result(i,j,n); if((s-1)%n==0) { flag = 0; break; } } if(!flag) continue; s = result(i,n-1,n); if((s-1)%n!=0) { flag = 0; continue; } sum++; } cout<<sum<<endl; return 0;}
B题
#include<cstdio>#include<iostream>#include<cstring>#include<stdlib.h>using namespace std;char str[1000010];int main(){ int i,j=0,k,n,a=0,f=0; char c; cin>>n; getchar(); for(i = 1; i <= n ; i++) { scanf("%c",&c); if(c=='A') a++; else if(c=='F') f++; else if(c=='I') j++; } if(j==1) cout<<"1"<<endl; else if(j==0) { cout<<a<<endl; } else cout<<"0\n"; return 0;}
C题 写挂了刚开始写了一半线段树 看到好多人过 觉得没那么难 就随便写了个 当时过了 之后 WA了 听队长说了简单方法
用一数组不断更新尾部应加的值 若删掉这个数 就把这个数值加到它的前一个 注意删掉之后 都更新为0
#include <iostream>#include<cstdio>#include<cstring>#include<stdlib.h>using namespace std;long long sum[1000010],x[1000010];int main(){ int i,j,k,n,m,a,b,c,g=1; x[g] = 0; long long s=0; cin>>n; while(n--) { cin>>a; if(a==1) { cin>>b>>c; sum[b] += c; s+=(b*c); printf("%.6lf\n",s*1.0/g); } else if(a==2) { cin>>b; g++; x[g] = b; s+=b; printf("%.6lf\n",s*1.0/g); } else { if(g>=2) { s-=(x[g]+sum[g]); sum[g-1]+=sum[g]; sum[g] = 0; x[g] = 0; g--; printf("%.6lf\n",s*1.0/g); } } } return 0;}
- Codeforces Round #174 (Div. 2)
- Codeforces Round #174 (Div. 2) Problem A
- Codeforces Round #174 (Div. 1)
- Codeforces Round #102 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #104 (Div. 2)
- Codeforces Round #105 (Div. 2)
- Codeforces Round #105 (Div. 2)
- Codeforces Round #107 (Div. 2)
- Codeforces Round #108 (Div. 2)
- Codeforces Round #110 (Div. 2)
- Codeforces Round #122 (Div. 2)
- Codeforces Round #121 (Div. 2)
- Codeforces Round #124 (Div. 2)
- Codeforces Round #124 (Div. 2)
- Codeforces Round #125 (Div. 2)
- Codeforces Round #124 (Div. 2)
- java.lang.String cannot be cast to java.util.Date
- Ubuntu-10.04.1下DirectFB与样例的编译安装、运行体验
- 块编程主题(三)
- 如何让IOS应用从容地崩溃
- nginx 学习笔录(支持thinkphp)
- Codeforces Round #174 (Div. 2)
- [代码片段] 【转】Android以最省内存的方式读取本地资源的
- 1.2 实验练习
- vsftpd不同用户访问不同目录的解决办法
- Portal-Basic Java Web 应用开发框架 v3.0.1 正式发布(源码、示例及文档)
- for_each使用方法详解[转]
- (转)解析bind1st和bind2nd的使用
- Druapl_让中英文切换器显示在Logo图片上
- 常用的一些动作 色彩渐变 转动、颤动 跳动 闪烁 放大 缩小