2011年7月5日

sicily 1133. SPAM

摘要: #include<iostream>#include<string>#include<string.h>#include<stdio.h>using namespace std;bool fit(char c){ if( (c>='A'&&c<='Z')||(c>='a'&&c<='z')||(c>='0'&&c<='9')||c=='_'||c==&# 阅读全文

posted @ 2011-07-05 02:19 sysu_mjc 阅读(207) 评论(0) 推荐(0) 编辑

sicily 1203. The Cubic End

摘要: // 题意: 以第一个例子说明, 给出123,求一个数的立方,使得尾数等于123,因为 947^3 = 849278123 ,则答案是947#include <iostream>#include <string>using namespace std;int compare(string str1, string str2){ while(!str1.empty()&&str1[0]=='0') { str1.erase(0,1); } while(!str2.empty()&&str2[0]=='0') 阅读全文

posted @ 2011-07-05 02:18 sysu_mjc 阅读(415) 评论(0) 推荐(0) 编辑

sicily 1294. 高级机密

摘要: #include <iostream> //快速幂取模#include <stdio.h>using namespace std;int power(int a,int b,int m) //快速幂取模计算 (a^b)%m{ if(a==0) return 0; else if(b==0) return 1; int r=a%m,k=1; while(b>1) { if((b&1)==1) k=(k*r)%m; r=(r*r)%m; b=b>>1... 阅读全文

posted @ 2011-07-05 02:15 sysu_mjc 阅读(189) 评论(0) 推荐(0) 编辑

sicily 1295. 负权数

摘要: //具体求解过程请参照郭老的ppt#include<iostream>#include<cstring>#include<cstdlib> //abs函数头文件using namespace std;int n,r,an,ar;int arr[100],len;int main(){ while(cin>>n) //在网上看到还能这么处理输入,好东西啊,之前因为无法用while(cin>>n>>r),所以傻乎乎地用getline(cin,str),再对str分拆成两个数来,之后还要判断n的正负,实在是麻烦... { if( 阅读全文

posted @ 2011-07-05 02:14 sysu_mjc 阅读(256) 评论(0) 推荐(0) 编辑

sicily 1214. 信号分析

摘要: //一道bt的题目,求解过程请看张大牛的ppt//变量要声明为unsigned int, 一直错, Fail at test case #10 ,改了就AC了#include<iostream>#include<cstring>#include<string>#include<math.h>using namespace std;int main(){ string str; unsigned int l; //题目要求 1<=L<2^32, 如果 声明为 int l; 则会WA Fail at test case #10 int l 阅读全文

posted @ 2011-07-05 02:09 sysu_mjc 阅读(418) 评论(0) 推荐(0) 编辑

sicily 1817. 校歌手大奖赛

摘要: #include<iostream> //二分,要注意用printf#include<stdio.h>using namespace std;int n,m,score[100][100];int mx(int j,int s,int t){ if(s==t) return score[s][j]; int mid=(s+t)>>1; int a=mx(j,s,mid),b=mx(j,mid+1,t); return max(a,b);}int mn(int j,int s,int t){ if(s==t) return score[s][j]; int m 阅读全文

posted @ 2011-07-05 02:07 sysu_mjc 阅读(130) 评论(0) 推荐(0) 编辑

sicily 1394. Root of the Problem

摘要: #include<iostream>#include<cmath>#include<cstdlib>using namespace std;int main(){ int b,n,s,t,s1,t1; while(cin>>b>>n&&b) { s=floor(pow(double(b),1.0/n)); t=ceil(pow(double(b),1.0/n)); if(s==t) cout<<s<<endl; else { s1=pow(double(s),double(n)); t1=pow 阅读全文

posted @ 2011-07-05 02:06 sysu_mjc 阅读(162) 评论(0) 推荐(0) 编辑

sicily 1483. 纪念品分组

摘要: #include<iostream> //贪心,每个分组尽量是两个纪念品的组合#include<algorithm>using namespace std;int main(){ int tag=0,n,w,p[30000]; while(cin>>w>>n) { if(tag) cout<<endl; else tag=1; for(int i=0;i<n;++i) cin>>p[i]; sort(p,p+n); int sum=n,s=0,t=n-1; //sum初始为n,表示每一组内只有一个纪念品 while( 阅读全文

posted @ 2011-07-05 02:05 sysu_mjc 阅读(310) 评论(0) 推荐(0) 编辑

sicily 1215. 脱离地牢

摘要: #include<iostream> //bfs#include<queue>using namespace std;struct node{ int si,sj,ti,tj,step; //(si,sj),(ti,tj)分别是Paris,Helen的位置,step是步数}fro,rear;queue<node> col;int n,m,vis[20][20][20][20];char ch[20][20],way[8]={'N','S','W','E'};int dis[8][2]={{-1, 阅读全文

posted @ 2011-07-05 02:03 sysu_mjc 阅读(246) 评论(0) 推荐(0) 编辑

sicily 1211. 商人的宣传

摘要: #include<iostream> //矩阵乘法,求从A到B的路线总数#include<cstring>using namespace std;int table[102][102],path[102][102],ans[102][102];int n,m,L,t,x,y,A,B;int main(){ cin>>n>>m>>L; while(m--) { cin>>x>>y; table[x][y]=1; path[x][y]=1; } while(--L) //循环L-1次 { memcpy(ans,pa 阅读全文

posted @ 2011-07-05 02:02 sysu_mjc 阅读(262) 评论(0) 推荐(0) 编辑

导航