摘要: 题目:Chat Servers Outgoing Traffic思路:水,map模拟#include #include #include #include #include #include #include using namespace std;mapm;int main(){ m.clear(); char s[110]; string str; int ans=0; while(gets(s)) { str=""; int l=strlen(s); if(s[0]=='+') { ... 阅读全文
posted @ 2013-07-13 13:45 over_flow 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.nyist.net/JudgeOnline/problem.php?pid=16思路:最长上升子序列#include #include #include #include #include using namespace std;struct node{ int x,y;}p[1010];int dp[1010];bool cmp(node a,node b){ if(a.x==b.x) return a.yp[i].y) swap(p[i].x,p[i].y); dp[i]=1; } sor... 阅读全文
posted @ 2013-07-13 11:11 over_flow 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=1061思路:扩展欧几里得#include #include #include #include #include using namespace std;long long gcd(long long a,long long b){ if(b==0) return a; return gcd(b,a%b);}long long exgcd(long long a,long long b,long long &x,long long &y){ if(b==0) { x=1; ... 阅读全文
posted @ 2013-07-12 21:32 over_flow 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.nefu.edu.cn/test/problemshow.php?problem_id=2思路:水#include #include #include #include #include using namespace std;#define maxn ((1>n) { int ans=0; for(int i=3;i=2) ans++; cout<<ans<<endl; } return 0;}View Code 阅读全文
posted @ 2013-07-12 21:23 over_flow 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.nefu.edu.cn/test/problemshow.php?problem_id=120思路:大数测试#include #include #include #include #include #include using namespace std;#define Times 10long long random(long long n){ return ((double)rand()/RAND_MAX*n+0.5);}long long multi(long long a,long long b,long long m){ long long a... 阅读全文
posted @ 2013-07-12 21:02 over_flow 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 题目:思路:水#include #include #include #include #include using namespace std;int main(){ int t; cin>>t; while(t--) { long long n; cin>>n; long long ans=0; long long cnt=5; while(cnt<=n) { ans+=n/cnt; cnt*=5; } cout<... 阅读全文
posted @ 2013-07-12 20:52 over_flow 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.nefu.edu.cn/test/problemshow.php?problem_id=117思路:水/* 求10^n内素数的个数的位数 = log(10)(num(n))+1 num(n) = n/ln(n) num(10^n) = 10^n/(n*ln(10)) = lg(10^n) - lg(n) - lg(ln(10)) + 1 = n+1 -lg(n) - lb(ln(10))*/#include #include #include #include #include using namespace std;int main(){ ... 阅读全文
posted @ 2013-07-12 20:51 over_flow 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.nefu.edu.cn/test/problemshow.php?problem_id=115题意:水#include #include #include #include #include using namespace std;int main(){ long long n; while(scanf("%lld",&n)!=EOF) { if(n%12==0) cout#include #include #include #include using namespace std;#define mod 12s... 阅读全文
posted @ 2013-07-12 20:49 over_flow 阅读(209) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.nefu.edu.cn/test/problemshow.php?problem_id=109题意:判断一个数是否是素数虽然这个题给的范围比较小,但是如果范围是一个__int64内的大数的话,就用到了先筛一部分素数再判断的方法,或者直接用大数测试#include #include #include #include #include #include using namespace std;#define maxn 45000int vis[maxn];mapm;void Prime(){ m.clear(); memset(vis,1,sizeof(v... 阅读全文
posted @ 2013-07-12 20:44 over_flow 阅读(281) 评论(0) 推荐(0) 编辑
摘要: 题目:Big Chocolate思路:很久之前写过,用递归一次一次的拆分的,写复杂了,直接输出m*n-1即可,证明自己想#include #include #include #include #include using namespace std;int main(){ long long m,n; while(scanf("%lld%lld",&m,&n)!=EOF) { cout<<m*n-1<<endl; } return 0;}View Code 阅读全文
posted @ 2013-06-23 10:07 over_flow 阅读(120) 评论(0) 推荐(0) 编辑