标签:nec cep ota code des ued otto mis 超时
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 77503 Accepted Submission(s): 24224
1 /* 2 Name: hdu--1013--Digital Roots 3 Copyright: 2017 日天大帝 4 Author: 日天大帝 5 Date: 22/04/17 10:34 6 Description: 这个题,就是特别坑 7 如果你一开始把所有的值设置为int型,恭喜你,你会得到一个WA 8 接着你大概会改成unsigned型,恭喜你,你会得到一个超时 9 然后你终于恍然大悟,用字符串!! 10 */ 11 #include<iostream> 12 #include<string> 13 using namespace std; 14 int main(){ 15 ios::sync_with_stdio(false); 16 17 string str; 18 while(cin>>str,str!="0") { 19 int sum = 0; 20 for(char ch:str)sum += ch-48; 21 while(sum>=10){ 22 int temp = sum; 23 sum = 0; 24 while(temp){ 25 sum += temp%10; 26 temp /= 10; 27 } 28 } 29 cout<<sum<<endl; 30 } 31 return 0; 32 }
标签:nec cep ota code des ued otto mis 超时
原文地址:http://www.cnblogs.com/rtdd/p/6747127.html