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,让你将其分成合数相加的形式,问你最多能够将其分成几个合数相加. 解题分析: 因为要将其分成合数相加的个数最多,所以自然是尽可能地将其分成尽可能小的合数 ...
随机推荐
- IDEA下基于MAVEN的SSM框架整合
源码可以以上传github https://github.com/ingxx/ssm_first 最近把用IDEA把SSM框架整合一遍遇到了不少坑,在这里写出来 这里maven我使用的是自己下载的3. ...
- 【Android】No resource found that matches the given name 'Theme.Sherlock.Light.NoActionBar'
被这个问题困扰了好久…… 错误如下: error: Error retrieving parent for item: No resource found that matches the given ...
- CoreCLR Host源码分析(C++)
废话不多说,直接上源码: 1.在托管程序集里面执行方法 HRESULT CorHost2::ExecuteAssembly(DWORD dwAppDomainId,//通过CreateAppDomai ...
- Serilog 自定义Enricher 来增加记录的信息
Serilog 自定义Enricher 来增加记录的信息 Intro Serilog 是 .net 里面非常不错的记录日志的库,结构化日志记录,而且配置起来很方便,自定义扩展也很方便 Serilog ...
- Spring文档学习
Spring文档学习 参考Spring Framework Documentation学习 1. IoC 容器 1.1 容器实例化 <beans> <import resource= ...
- AVL树(查找、插入、删除)——C语言
AVL树 平衡二叉查找树(Self-balancing binary search tree)又被称为AVL树(AVL树是根据它的发明者G. M. Adelson-Velskii和E. M. Land ...
- testlink搭建教程
1,下载testlink安装包 请加QQ群299524235,在群文件中下载 2.配置Apache环境和PHP环境 解压testlink文件到Apache中, 通过127.0.0.1/ ...
- 【干货】基于镜像部署的Gitlab-CI/CD实践和坑位指南
引言 看过前文的博友可能注意到我是把 部署dll文件拷贝到生产机器,之后在生产机器上使用docker-compose即时创建镜像, 并没有完成CI/CD, 只是在原来传统部署方式下 将部署文件容器化. ...
- SpringCloud微服务小白入门之Eureka注册中心和服务中心搭建示例
一.注册中心配置文件 代码复制区域: spring: application: name: spring-cloud-server server: port: 7000 eureka: instanc ...
- element-ui表单验证无效解决
最近在项目中遇到了一个需求,需要动态增减表单元素,同时给新增的表单元素增加校验规则. element-ui官网给出了解决方案:点击新增按钮时,向循环渲染的数组中push新的对象,数据驱动视图,通过增加 ...