zoukankan      html  css  js  c++  java
  • UVA 10494 If We Were a Child Again

    //做这种题我知道了,以后数字能定多大就定多大,最后就long long int,前面都是把数字定义为int,老是WA
    #include <iostream> #include <string> #include <sstream> #include <algorithm> using namespace std; int main() { string str1,str2,str3; while(cin>>str1>>str2>>str3) { unsigned long int p = 0; unsigned long int n; char op = str2[0]; istringstream(str3)>>n; for(int i = 0 ,len = str1.length(); i < len ;++i ) { unsigned long int temp = p*10+ str1[i]-'0' ; p = temp%n; str1[i] = temp/n; } if(op == '/') { transform(str1.begin(),str1.end() , str1.begin() , bind1st(plus<int>(),48)); int pos = str1.find_first_not_of('0'); if(pos == string::npos) cout<<"0"<<endl; else cout<<str1.substr(pos)<<endl; } else if(op == '%') { cout<<p<<endl; } } return 0; }
  • 相关阅读:
    UVA
    UVA
    母函数
    快速排序
    集合:set
    stringstream转换
    大学期间的任务
    Devc++贪吃蛇
    Vector容器
    广度优先遍历
  • 原文地址:https://www.cnblogs.com/UnGeek/p/2571437.html
Copyright © 2011-2022 走看看