Educational Codeforces Round 23
分析:注意两个点之间的倍数差,若为偶数则为YES,否则为NO
#include "iostream"
#include "cstdio"
#include "cstring"
#include "string"
#include "cmath"
using namespace std;
int main()
{
int x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
int x,y;
cin>>x>>y;
int cnt1=x2-x1;
int cnt2=y2-y1;
int flag=;
if(cnt1%x){
flag=;
}
if(cnt2%y){
flag=;
}
if(abs(abs(cnt1/x)-abs(cnt2/y))%){
flag=;
}
if(!flag){
cout<<"YES"<<endl;
}else{
cout<<"NO"<<endl;
}
}
分析:先看只用第一个数是否满足情况,如果不行在加入第二个数,不行在加入第三个数,如此分别统计三种情况即可
#include "iostream"
#include "cstdio"
#include "cstring"
#include "string"
#include "algorithm"
#include "set"
#include "vector"
using namespace std;
const int maxn=+;
long long a[maxn];
int n;
long long solve3(long long sum){
return (sum*(sum-)*(sum-)/);
}
long long solve2(long long sum){
return (sum*(sum-)/);
}
int main()
{
cin>>n;
for(int i=;i<n;i++)
cin>>a[i];
sort(a,a+n);
set<long long>h;
for(int i=;i<n;i++){
h.insert(a[i]);
}
set<long long>::iterator it;
vector<long long>q;
for(it=h.begin();it!=h.end();it++){
q.push_back(*it);
}
long long cnt1=,cnt2=,cnt3=;
for(int i=;i<n;i++){
if(a[i]==q[]){
cnt1++;
}else if(a[i]==q[]){
cnt2++;
}else if(a[i]==q[]){
cnt3++;
}
}
if(cnt1>=){
cout<<solve3(cnt1)<<endl;
}else if(cnt1==){
cout<<cnt2<<endl;
}else{
if(cnt2>=){
cout<<solve2(cnt2)<<endl;
}else{
cout<<cnt3<<endl;
}
}
return ;
}
分析:因为两个数的差值最大不会超过18*9=162,所以直接暴力即可
#include "iostream"
#include "cstdio"
#include "cstring"
using namespace std;
long long a,b;
long long solve(long long num){
long long ans=;
while(num){
long long mod=num%;
ans+=mod;
num/=;
}
return ans;
}
int main()
{
cin>>b>>a;
long long sum=b-a;
if(sum<=){
cout<<""<<endl;
return ;
}
long long cnt=;
if(b-a<=){
for(long long i=a;i<=b;i++){
long long tt=i;
//cout<<b-solve(tt)<<endl;
if((i-solve(tt))>=a)
cnt++;
}
cout<<cnt<<endl;
}else{
for(long long i=a;i<=a+;i++){
long long yy=i;
if((i-solve(yy))<a)
cnt++;
}
cout<<sum-cnt+<<endl;
}
return ;
}
Educational Codeforces Round 23的更多相关文章
- Educational Codeforces Round 23 E. Choosing The Commander trie数
E. Choosing The Commander time limit per test 2 seconds memory limit per test 256 megabytes input st ...
- Educational Codeforces Round 23.C
C. Really Big Numbers time limit per test 1 second memory limit per test 256 megabytes input standar ...
- Educational Codeforces Round 23 B. Makes And The Product
B. Makes And The Product time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- Educational Codeforces Round 23 F. MEX Queries 离散化+线段树
F. MEX Queries time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- Educational Codeforces Round 23 D. Imbalanced Array 单调栈
D. Imbalanced Array time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Educational Codeforces Round 23 C. Really Big Numbers 暴力
C. Really Big Numbers time limit per test 1 second memory limit per test 256 megabytes input standar ...
- Educational Codeforces Round 23 补题小结
昨晚听说有教做人场,去补了下玩. 大概我的水平能做个5/6的样子? (不会二进制Trie啊,我真菜) A. 傻逼题.大概可以看成向量加法,判断下就好了. #include<iostream> ...
- Educational Codeforces Round 23 A-F 补题
A Treasure Hunt 注意负数和0的特殊处理.. 水题.. 然而又被Hack了 吗的智障 #include<bits/stdc++.h> using namespace std; ...
- Educational Codeforces Round 40千名记
人生第二场codeforces.然而遇上了Education场这种东西 Educational Codeforces Round 40 下午先在家里睡了波觉,起来离开场还有10分钟. 但是突然想起来还 ...
随机推荐
- (4)Swing布局
一.FlowLayout-流布局 新增第一个组件后默认在第一行的居中位置,之后 组件按照加入的先后顺序按照设置的对齐方式从左向右排列 二.borderLayout-边框布局 容器划分为东.西.南.北. ...
- rsync故障排查整理
1.客户端的错误现象:No route to host rsync服务端开启了iptables防火墙 rsync -avz /etc/hosts rsync_backup@172.16.1.41::b ...
- Java全局变量不加修饰符时的访问权限范围
如上图所示.
- 高性能JS-DOM
用脚本进行DOM操作的代价是很昂贵的,它是富web应用中最常见的性能瓶颈.主要有以下三种问题: 访问和修改DOM元素 修改DOM元素的样式导致repaint和reflow 通过DOM事件处理与用户进行 ...
- Word中将文本框、图形对象中的文本边距调整
在进行word的实际使用中,如下图制作流程图时,常常发现文字在图形对象中,老是显示不全,而且上部却空出很多距离.此时可以通过设置形状格式--文本框 --- 上.下编辑进行设置. 可以完美解决文本框中文 ...
- 优秀的数据序列和还原类----TSimpleMsgPack
优秀的数据序列和还原类----TSimpleMsgPack TSimpleMsgPack是D10天地弦的作品. 优点:至简,就一个单元文件实现,不需要引用其他单元. 缺点:不是标准的MSGPACK实现 ...
- 边看chromium的代码,边想骂人...
这一年一直在看chromium for android的代码,边看边想骂,谷歌这帮人..一开始搞了个牛逼的架构,在安卓4.4上把以前android webkit团队的简单版替换掉了,结果发现性能大不如 ...
- Python学习系列之logging模块
实例一:日志写进一个文件 代码: import logging logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(filen ...
- 上传jar包至maven私服
1.maven环境变量配置(新建系统变量,编辑Path) 2.修改maven的setting文件 2.1 私服的用户配置 2.2 私服镜像配置 2.3 (我也不知道是啥) <profile> ...
- 有关不同浏览器不同版本号的css以及js计算高度的问题
1.input在全部浏览器以及全部的版本号中,都是定义了高度.然后再定义padding或者border值.这时候都会撑开.高度是本身的高度在padding值和border值 2.select在gool ...