zoukankan      html  css  js  c++  java
  • POJ 1519 Digital Roots

    题意:求数根。

    解法:一个数的数根就是mod9的值,0换成9,只是没想到给的是一个大数……只好先把每位都加起来再mod9……

    代码:

    #include<stdio.h>
    #include<iostream>
    #include<algorithm>
    #include<string>
    #include<string.h>
    #include<math.h>
    #include<limits.h>
    #include<time.h>
    #include<stdlib.h>
    #include<map>
    #include<queue>
    #include<set>
    #include<stack>
    #include<vector>
    #define LL long long
    
    using namespace std;
    
    int main()
    {
        string s;
        while(cin >> s)
        {
            if(s == "0") break;
            int ans = 0;
            for(int i = 0; i < s.size(); i++)
                ans += s[i] - '0';
            ans %= 9;
            if(!ans) ans = 9;
            cout << ans << endl;
        }
        return 0;
    }
    

      

  • 相关阅读:
    slenium截屏
    效率提升
    R语言网页爬虫
    高性能计算
    数据操作
    数据库操作
    面向对象编程
    元编程
    R 的内部机制
    数据处理
  • 原文地址:https://www.cnblogs.com/Apro/p/4849042.html
Copyright © 2011-2022 走看看