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分钟. 但是突然想起来还 ...
随机推荐
- ROS下使用ASUS Xtion Pro Live
一.ROS官网hydro版本OpenNI安装 3. Installation 3.1 Ubuntu installation To install only openni_camera: sudo a ...
- unix grep命令的大致实现
用到了strstr(a,b)函数和getline()函数,strstr(a,b)函数看是否能在字符串a中找到字符串b,若找到返回指向,若没找到返回NULL strstr实现可以看:Implement ...
- FFT/NTT模板 既 HDU1402 A * B Problem Plus
@(学习笔记)[FFT, NTT] Problem Description Calculate A * B. Input Each line will contain two integers A a ...
- 【Java TCP/IP Socket】TCP Socket(含代码)
TCP的Java支持 协议相当于相互通信的程序间达成的一种约定,它规定了分组报文的结构.交换方式.包含的意义以及怎样对报文所包含的信息进行解析,TCP/IP协议族有IP协议.TCP协议和UDP协议.现 ...
- Java全局变量不加修饰符时的访问权限范围
如上图所示.
- LucaCanali--SystemTap_Linux_IO
https://github.com/LucaCanali/Linux_tracing_scripts/tree/master/SystemTap_Linux_IO
- Spring自带mock测试Controller
原文:http://blog.csdn.net/yin_jw/article/details/24726941 准备SpringMVC环境 注意:使用mock测试需要引入spring-test包 Ba ...
- init.rc文件中面启动c++程序,通过jni调用java实现
</pre><p>注:假设是自己的myself.jar包,还要修改例如以下:</p><p>target/product/core_base.mk PRO ...
- 第21章、OnItemSelectedListener事件(从零开始学Android)
在Android App应用中,OnItemSelectedListener事件也会经常用到,我们一起来了解一下. 基本知识点:OnItemSelectedListener事件 一.界面 1.新建pr ...
- BUPT复试专题—中序遍历序列(2013)
题目描述 给出一个序列,判断该序列是不是某二叉搜索树的中序遍历序列,如果是输出"Yes",否则输出"No".一颗带权二叉树是一颗二叉搜索树(二叉排序树),当且仅 ...