• 数位的处理


    Problem H. Math Game

    Input file:                  standard input

    Output file:               standard output

    Time limit:                1 seconds

    Memory limit:          128 megabytes

    大家都知道马大佬很皮

    马大佬很喜欢研究数字的数位和,现在马大佬手里有 n 个数字,他想知道这 n 个数字里 面有多少个数字的数位和是 7 的倍数?

    Input

    输入第一行一个整数 T,代表接下来有 T 组测试数据 对于每一组测试数据,先输入一个整数 n 代表 n 个数字 接下来一行输入 n 个数 a[i],代表每一个数字

    1 <= T <= 10,1 <= n <= 2*105 ,1 <= a[i] <= 10^9

    Output

    对于每一组测试数据,输出对应答案。

    Example

     

    standard input

    standard output

    1

    5

    16 2 7 14 95

    3

    #include<iostream>
    #include<cstring>
    #define N 200000
    using namespace std;
    
    int main()
    {
        int t,a[N];
        memset(a,0,sizeof(a));
        cin >> t;//样例个数 
        
        while(t--)
        {
            
            int n,sum = 0;
            cin >> n;//单个样例的个数 
            
            for(int i = 1;i <= n;i++)
            {
                int x;
                cin >> x;
                int ans = 0;
                while(x)//对刚读入的数立刻进行处理 
                {
                    ans += x % 10;
                    x = x / 10;
                }
                if(ans % 7 == 0)
                    sum++;
            }
            cout << sum << endl;
        }
    
        return 0;
    }

    嵌套三层循环

  • 相关阅读:
    python操作Excel读写--使用xlrd
    python 使用pymssql连接sql server数据库
    python pdb调试
    sqlser生成guid与复制造数
    sqlser游标与for循环
    bat写循环
    Jenkins配置多任务
    git命令行与Jenkins
    Jenkins执行python脚本
    Windows环境Jenkins配置免密登录Linux
  • 原文地址:https://www.cnblogs.com/biaobiao88/p/11669432.html
Copyright © 2020-2023  润新知