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=; i<=n; i++)
{
scanf("%lld", &x);
int ans = x/;
int tmp = x%;
if(x==||x==||x==||x==||x==||x==)
{
puts("-1");
continue;
}
if(tmp==||tmp==)ans--;
printf("%d\n",ans);
}
return ;
}
codeforce440C-Maximum splitting-规律题的更多相关文章
- LightOJ1010---Knights in Chessboard (规律题)
Given an m x n chessboard where you want to place chess knights. You have to find the number of maxi ...
- Maximum splitting
Maximum splitting You are given several queries. In the i-th query you are given a single positive i ...
- Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination Round 2) C. Maximum splitting
地址: 题目: C. Maximum splitting time limit per test 2 seconds memory limit per test 256 megabytes input ...
- Codeforces - 规律题 [占坑]
发现自己容易被卡水题,需要强行苟一下规律题 CF上并没有对应的tag,所以本题集大部分对应百毒搜索按顺序刷 本题集侧重于找规律的过程(不然做这些垃圾题有什么用) Codeforces - 1008C ...
- codeforces Round #440 C Maximum splitting【数学/素数与合数/思维/贪心】
C. Maximum splitting time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- ACM_送气球(规律题)
送气球 Time Limit: 2000/1000ms (Java/Others) Problem Description: 为了奖励近段时间辛苦刷题的ACMer,会长决定给正在机房刷题的他们送气球. ...
- hdoj--1005--Number Sequence(规律题)
Number Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- Maximum splitting(规律,数论)
You are given several queries. In the i-th query you are given a single positive integer ni. You are ...
- Codeforces Round #452 (Div. 2)-899A.Splitting in Teams 899B.Months and Years 899C.Dividing the numbers(规律题)
A. Splitting in Teams time limit per test 1 second memory limit per test 256 megabytes input standar ...
- Codeforces 870C Maximum splitting (贪心+找规律)
<题目链接> 题目大意: 给定数字n,让你将其分成合数相加的形式,问你最多能够将其分成几个合数相加. 解题分析: 因为要将其分成合数相加的个数最多,所以自然是尽可能地将其分成尽可能小的合数 ...
随机推荐
- SpringBoot RabbitMQ 整合使用
 ### 前提 上次写了篇文章,[<SpringBoot ...
- Broadcast 使用详解
极力推荐文章:欢迎收藏 Android 干货分享 阅读五分钟,每日十点,和您一起终身学习,这里是程序员Android 本篇文章主要介绍 Android 开发中的部分知识点,通过阅读本篇文章,您将收获以 ...
- 商贸型企业 Java 收货 + 入库 + 生成付款单
package cn.hybn.erp.modular.system.service.impl; import cn.hybn.erp.core.common.page.LayuiPageFactor ...
- containerd与kubernetes集成
kubernetes集群三步安装 概念介绍 cri (Container runtime interface) cri is a containerd plugin implementation of ...
- elk系列教程:docker中安装配置elk
elasticSearch Docker安装elasticsearch: docker pull docker.io/elasticsearch:7.2.0 启动: docker run -p 920 ...
- 消息中间件-activemq安全机制
activemq作为消息中间件这样一个独立的个体存在,连通用户和服务器.如果没有一套完备的安全机制去设置用户权限设置消息分发机制可想后果是非常严重.ActiveMQ如果不加入安全机制的话,任何人只要知 ...
- HBuilderX使用Vant组件库
HBuilderX使用Vant组件库 HBuilderX是一款由国人开发的开发工具,其官网称其为轻如编辑器.强如IDE的合体版本.但是官方的社区中关于Vant组件的安装大多都是针对微信小程序开发安装V ...
- byte数组和正数BigInteger之间的相互转换
旧代码 public static void main(String[] args) { SecureRandom random = new SecureRandom(); byte[] key = ...
- java Timer工具类实现定时器任务
第一 schedule 方法 三个参数 按照顺序 (执行的任务方法,开始执行时间,多少时间后循环去执行) 代码可用 public class TestScheedule { public stati ...
- Linux:oracle11.2.0dbca静默建库
1.关闭防火墙 systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #禁止firewall ...