摘要:
一开始做这题时大脑短路……连用浮点数来表示都没想到,所以我的做法是取1~n的对数,然后加起来,再减去一个整数使那个浮点在1~2的范围内,pow10以后取个位,答案就出来了。后来想想,用浮点这题有可能也做得出来,不大可能出现误差的~ P.S. 今天刚刚发现浮点没法做。long double的范围只到10的4000多次,而100000!可以到10的450000多次!所以用浮点不现实的了~~ #incl... 阅读全文
posted @ 2005-08-21 21:15
Fancy Mouse
阅读(440)
评论(1)
推荐(0)
摘要:
又是一道简单的题,直接照题意编就是了 #includeusing namespace std;const int MAX = 250;int main(){ char buffer[MAX],text[MAX]; int p,t; while(cin.getline(buffer,MAX)) { for(p=t=0;p<250 && buffer[p]!='\... 阅读全文
posted @ 2005-08-21 21:03
Fancy Mouse
阅读(353)
评论(2)
推荐(0)
摘要:
Maigo大牛有一句很经典的比喻:“一个2跟一个5反应生成一个0,因为2过量,所以照5算”没错,只要算1~n这n个数里面一共有多少5因子就可以了 #includeusing namespace std;int main(){ int n=0,zeros=0; while(cin>>n) { while(n>=5) { n/=5; ... 阅读全文
posted @ 2005-08-21 21:01
Fancy Mouse
阅读(357)
评论(1)
推荐(0)
摘要:
从字符串头上开始贪心,保证最优解比较字符的时候大于小于等于都表忘记考虑~~ #includeusing namespace std;void CutDigit(char num[],int index);void HeadCalc(char num[],int rest);int main(){ char num[260]; int rest; while(cin>>num>>r... 阅读全文
posted @ 2005-08-21 20:58
Fancy Mouse
阅读(421)
评论(1)
推荐(0)
摘要:
没什么好说的了,标准链表题。 #includeusing namespace std;class LinkedList{public: LinkedList* Next; int Number; int Password; void DeleteNext(); LinkedList* Append(int Number,int Password); Li... 阅读全文
posted @ 2005-08-21 20:52
Fancy Mouse
阅读(485)
评论(1)
推荐(0)
摘要:
可以用大数类存放末几位的数字。乘出来有0就舍去。这是我的代码:(用long long即64位整形变量来计算) #includeusing namespace std;int main(){ unsigned long long n,t,sum,temp; while(cin>>n) { for(t=temp=1,sum=0;t<=n;t++) { ... 阅读全文
posted @ 2005-08-21 20:49
Fancy Mouse
阅读(620)
评论(7)
推荐(0)
摘要:
此题有多种做法,直接数也行(枚举所有数然后判断有多少质数);或者维护一个质数列表,输入两个数以后搜索有几个质数。我用的是前者 #include#includeusing namespace std;int IsPrime(long Num);int main(){ long int n,m,sum; while(cin>>n>>m) { sum=0; ... 阅读全文
posted @ 2005-08-21 17:47
Fancy Mouse
阅读(588)
评论(4)
推荐(0)
摘要:
列一个关于行和列的通式吧第n行第m列一定是f(n,m)这个数……然后把函数一般式求出来就ok了 #includeusing namespace std;int main(){ int t,line,row; while(cin>>t) { for(line=0;line<t;line++) { cout<<line*(line+1... 阅读全文
posted @ 2005-08-21 17:45
Fancy Mouse
阅读(350)
评论(1)
推荐(0)
摘要:
杨辉三角~~画一个矩阵然后按照定义算吧 #includeusing namespace std;#define N 34void Triangle(int Num);int main(){ int n,datas=1; while(cin>>n) { if(datas>1) cout0 && Line==Row) cout<<' '; ... 阅读全文
posted @ 2005-08-21 17:43
Fancy Mouse
阅读(501)
评论(2)
推荐(0)
摘要:
没意思的题……讲编程语言的书都有说明的 #includeusing namespace std;int main(){ int sum=0,a; while(cin>>a) sum+=a; cout<<sum<<endl; return 0;} 阅读全文
posted @ 2005-08-21 17:41
Fancy Mouse
阅读(350)
评论(1)
推荐(0)
摘要:
直接用定义去做吧,不会tle的 #includeusing namespace std;int IsSevens(int Number);int main(){ int Max,c; cin>>Max; for(c=7;c0) { if(Number % 10 == 7) return 1; else Number/=10; } re... 阅读全文
posted @ 2005-08-21 17:40
Fancy Mouse
阅读(461)
评论(1)
推荐(0)
摘要:
类似Fibonacci数列,记得这种题用递归做你就死翘翘了(复杂度O(2^N))。好歹也应该设一个数组再递推的(复杂度O(N))关于Fibonacci数列,TJU1248的难度……偶现在还是tle……努力思索中,哈哈~~帖1005的代码: #includeusing namespace std;int Cows(int Years);int main(){ int yrs,cow; w... 阅读全文
posted @ 2005-08-21 12:12
Fancy Mouse
阅读(662)
评论(4)
推荐(0)
摘要:
呵呵~~经典动态规划题。当然,这题的数据规模不大,所以就算搜索也不会tle。当然,最好的办法还是动规。这里我用的是搜索+剪枝的办法。仔细分析一下题目,求一套导弹系统能击落多少导弹就是问你这个数列中最长的不下降(降序)子序列。求要多少导弹系统才能击落所有导弹就是问你这个数列中最长的上升(升序)子序列。第二点我说明一下,一个数列必定存在升序子序列,这个序列里面的任何两个数(两颗导弹)不能被分在一起(被... 阅读全文
posted @ 2005-08-21 12:10
Fancy Mouse
阅读(788)
评论(1)
推荐(0)
摘要:
也米有什么好说的了,直接做就行了 #includeusing namespace std;int main(){ int N,temp,temp2; cin>>N; char s='A'; for(temp=0;temp0;temp2--) cout0;temp2--) cout<<s; cout<<endl; s++; } retu... 阅读全文
posted @ 2005-08-21 12:03
Fancy Mouse
阅读(379)
评论(1)
推荐(0)
摘要:
经典的递归题。一层递归确定一个字母,第一层确定第一个字母。而确定字母是通过字符交换来实现排列的~~说的晦涩了一些,看代码吧: #includeusing namespace std;void Permulate(char s[],int start,int all);void Copy(char a[],char b[],int i);int main(){ char s[10]; c... 阅读全文
posted @ 2005-08-21 12:02
Fancy Mouse
阅读(745)
评论(2)
推荐(0)
摘要:
第一个正式题。注意它的样例输出,Y和U是在第三列上,因此他们前面都要打两个space而不是一个。 代码如下: #includeusing namespace std;int abs(int Number);int main(){ int Lines,count1,count2; char c='Z'; cin>>Lines; for(count1=Lines-1;abs(c... 阅读全文
posted @ 2005-08-21 12:00
Fancy Mouse
阅读(729)
评论(4)
推荐(0)
摘要:
http://acm.tongji.edu.cn/showproblem.php?problem_id=1000 这个……呃……TOJ上面没给出C++的代码,偶就用C++写一个(别说我无聊哈) #includeusing namespace std;int main(){ int a,b; cin>>a>>b; cout<<a+b<<endl; return 0;} 阅读全文
posted @ 2005-08-21 11:55
Fancy Mouse
阅读(586)
评论(1)
推荐(0)
摘要:
http://acm.tongji.edu.cn 这几天由于做TOJ的题,所以没怎么有空更新blog。现在把部分已经ac的题的题解献上来~~(随时更新~~) 这里先附上简单的提示,详细点的题解请点链接,题解附C++代码。 某些词语解释:ac->Accepted通过;wa->Wrong Answer错误答案;tle->Time Limit Exceeded 超时;mle->M... 阅读全文
posted @ 2005-08-21 11:44
Fancy Mouse
阅读(4099)
评论(5)
推荐(0)
浙公网安备 33010602011771号