zoukankan      html  css  js  c++  java
  • codeforce440C-Maximum splitting-规律题

    题意:问一个数最多可以变成几个合数的和;

    思路:

    时刻提醒自己再看到题目的时候的所作所为,该找规律找规律,想什么ksm,质数判断开根号。

    除了1、2、3、5、7、11外,其余的数都可以通过4,6,9获得,所以只要用x对4取余,结果为1或3,ans都要减1;

    (1、3-->9 ;  2-->6 )

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <cstring>
    #include <string>
    #include <vector>
    #include <map>
    #include <set>
    #include <queue>
    #include <list>
    #include <iterator>
    #include <cmath>
    using namespace std;
    
    typedef long long ll;
    
    
    int n,k;
    ll x;
    
    int main(){
        
        scanf("%d", &n);
        for(int i=1; i<=n; i++)
        {
            scanf("%lld", &x);
            int ans = x/4;
            int tmp = x%4;
            if(x==1||x==2||x==3||x==5||x==7||x==11)
            {
                puts("-1");
                continue;
            }
            if(tmp==3||tmp==1)ans--;
            printf("%d
    ",ans);
        }
        return 0;
    }
  • 相关阅读:
    app测试点-1
    毕业5年的感悟
    关于游戏外挂
    python-unittest单元测试框架
    python-requests
    http简介
    python基础-发邮件smtp
    python-加密
    4 Python 日期和时间
    5 Python 数据类型—数字
  • 原文地址:https://www.cnblogs.com/ckxkexing/p/9027127.html
Copyright © 2011-2022 走看看