Codeforces Round #426 (Div. 2) A,B,C
A. The Useless Toy
题目链接:http://codeforces.com/contest/834/problem/A
思路: 水题
实现代码:
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<list>
using namespace std;
#define ll long long
#define sd(x) scanf("%d",&x)
#define sdd(x,y) scanf("%d%d",&x,&y)
#define sddd(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sf(x) scanf("%s",x)
#define ff(i,x,y) for(int i = x;i <= y;i ++)
#define fj(i,x,y) for(int i = x;i >= y;i --)
#define mem(s,x) memset(s,x,sizeof(s));
#define pr(x) printf("%d",x);
const int Mod = 1e9+;
const int inf = 1e9;
const int Max = 1e5+;
void exgcd(ll a,ll b,ll& d,ll& x,ll& y){if(!b){d=a;x=;y=;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}
ll inv(ll a,ll n){ll d, x, y;exgcd(a,n,d,x,y);return (x+n)%n;}
int gcd(int a,int b) { return (b>)?gcd(b,a%b):a; }
int lcm(int a, int b) { return a*b/gcd(a, b); }
ll mod(ll x,ll y){
return x-(x/y)*y;
}
int main()
{
ios::sync_with_stdio();
cin.tie();
char a[];
ll k,b[];
cin>>a[]>>a[];
cin>>k;
for(int i=;i<=;i++){
if(a[i]=='v') b[i] = ;
if(a[i]=='<') b[i] = ;
if(a[i]=='^') b[i] = ;
if(a[i]=='>') b[i] = ;
}
ll ans1 = mod(k+b[],);
ll ans2 = mod(b[]-k,);
while(ans2<)
ans2+=;
if(b[]==ans1&&b[]==ans2)
cout<<"undefined"<<endl;
else if(b[]==ans2)
cout<<"ccw"<<endl;
else if(b[]==ans1)
cout<<"cw"<<endl;
return ;
}
B. The Festive Evening
题目链接:http://codeforces.com/contest/834/problem/B
思路; 水题
实现代码:
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<list>
using namespace std;
#define ll long long
#define sd(x) scanf("%d",&x)
#define sdd(x,y) scanf("%d%d",&x,&y)
#define sddd(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sf(x) scanf("%s",x)
#define ff(i,x,y) for(int i = x;i <= y;i ++)
#define fj(i,x,y) for(int i = x;i >= y;i --)
#define mem(s,x) memset(s,x,sizeof(s));
#define pr(x) printf("%d",x);
const int Mod = 1e9+;
const int inf = 1e9;
const int Max = 1e5+;
void exgcd(ll a,ll b,ll& d,ll& x,ll& y){if(!b){d=a;x=;y=;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}
ll inv(ll a,ll n){ll d, x, y;exgcd(a,n,d,x,y);return (x+n)%n;}
int gcd(int a,int b) { return (b>)?gcd(b,a%b):a; }
int lcm(int a, int b) { return a*b/gcd(a, b); }
ll mod(ll x,ll y){ return x-(x/y)*y;}
char s[];
map<char,int>mp;
set<char>st;
int main()
{
int n,m,cnt=,i,vis[];
ios::sync_with_stdio();
cin.tie();
cin>>n>>m;
mp.size();
for(i=;i<n;i++){
cin>>s[i];
mp[s[i]]=i;
}
for(i=;i<n-;i++){
st.insert(s[i]);
if(st.size()>m){
cout<<"YES"<<endl;
return ;
}
if(mp[s[i]]==i)
st.erase(s[i]);
}
cout<<"NO"<<endl;
return ;
}
C. The Meaningless Game
题目链接:http://codeforces.com/contest/834/problem/C
思路:二分,a,b分别*k或*k^2,那么a*b必为k*(k^2)*(k1^2)*k1*.....也就是 (k*k1*..)^3,直接二分搜a*b是否为某个数的三次方,输入输出数据比较大,用scanf和print.要不超时
实现代码:
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<list>
using namespace std;
#define ll long long
#define sd(x) scanf("%d",&x)
#define sdd(x,y) scanf("%d%d",&x,&y)
#define sddd(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sf(x) scanf("%s",x)
#define ff(i,x,y) for(int i = x;i <= y;i ++)
#define fj(i,x,y) for(int i = x;i >= y;i --)
#define mem(s,x) memset(s,x,sizeof(s));
#define pr(x) printf("%d",x);
const int Mod = 1e9+;
const int inf = 1e9;
const int Max = 1e5+;
void exgcd(ll a,ll b,ll& d,ll& x,ll& y){if(!b){d=a;x=;y=;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}
ll inv(ll a,ll n){ll d, x, y;exgcd(a,n,d,x,y);return (x+n)%n;}
int gcd(int a,int b) { return (b>)?gcd(b,a%b):a; }
int lcm(int a, int b) { return a*b/gcd(a, b); }
int main()
{
ll n,i,mid,l,r,a,b;
cin>>n;
for(i=;i<n;i++){
scanf("%I64d %I64d",&a,&b);
l=;r=;
int flag = ;
while(l<=r){
mid = (l+r)/;
//cout<<Pow(mid,3)<<" "<<a*b<<endl;
if(mid*mid*mid==a*b){
flag = ;break;}
if(mid*mid*mid>a*b)
r = mid-;
if(mid*mid*mid<a*b)
l = mid+;
}
if(flag&&a*a%b==&&b*b%a==)
printf("Yes\n");
else
printf("No\n");
}
return ;
}
Codeforces Round #426 (Div. 2) A,B,C的更多相关文章
- CodeForces 834C - The Meaningless Game | Codeforces Round #426 (Div. 2)
/* CodeForces 834C - The Meaningless Game [ 分析,数学 ] | Codeforces Round #426 (Div. 2) 题意: 一对数字 a,b 能不 ...
- Codeforces Round #426 (Div. 2)【A.枚举,B.思维,C,二分+数学】
A. The Useless Toy time limit per test:1 second memory limit per test:256 megabytes input:standard i ...
- Codeforces Round #426 (Div. 2)
http://codeforces.com/contest/834 A. The Useless Toy 题意: <,>,^,v这4个箭头符号,每一个都可以通过其他及其本身逆时针或者顺时针 ...
- Codeforces Round #426 (Div. 2) C. The Meaningless Game
C. The Meaningless Game 题意: 两个人刚刚开始游戏的时候的分数, 都是一分, 然后随机一个人的分数扩大k倍,另一个扩大k的平方倍, 问给你一组最后得分,问能不能通过游戏得到这样 ...
- Codeforces Round #426 (Div. 2)A B C题+赛后小结
最近比赛有点多,可是好像每场比赛都是被虐,单纯磨砺心态的作用.最近讲的内容也有点多,即便是点到为止很浅显的版块,刷了专题之后的状态还是~"咦,能做,可是并没有把握能A啊".每场网络 ...
- Codeforces Round #426 (Div. 2)A题&&B题&&C题
A. The Useless Toy:http://codeforces.com/contest/834/problem/A 题目意思:给你两个字符,还有一个n,问你旋转n次以后从字符a变成b,是顺时 ...
- 【Codeforces Round #426 (Div. 2) A】The Useless Toy
[Link]:http://codeforces.com/contest/834/problem/A [Description] [Solution] 开个大小为4的常量字符数组; +n然后余4,-n ...
- 【Codeforces Round #426 (Div. 2) B】The Festive Evening
[Link]:http://codeforces.com/contest/834/problem/B [Description] [Solution] 模拟水题; 注意一个字母单个出现的时候,结束和开 ...
- 【Codeforces Round #426 (Div. 2) C】The Meaningless Game
[Link]:http://codeforces.com/contest/834/problem/C [Description] 有一个两人游戏游戏; 游戏包括多轮,每一轮都有一个数字k,赢的人把自己 ...
随机推荐
- 1-STM32嵌入LUA开发(控制小灯闪耀)
今天因为想让STM32完美的处理字符串,所以就想着让STM32嵌入lua,本来想用f103c8t6,但是一编译就提示内存不足...... 所以单片机的型号选择的 \ 我下载到了RBT6的芯片上测试的 ...
- 通过Jekins执行bat脚本始终无法完成
问题描述 最近在研究Devops工作流,中间有一个环节是自动发布版本的,我们使用PipeLine调用Jekins任务,最终执行bat脚本,但在执行Jekins任务的时候,任务总是完成不了,导致DBA在 ...
- OI骗分神器——模拟退火算法
前言&&为什么要学模拟退火 最近一下子学了一大堆省选算法,所以搞一个愉快一点的东西来让娱乐一下 其实是为了骗到更多的分,然后证明自己的RP. 说实话模拟退火是一个集物理与IT多方面知识 ...
- virtual box问题记录
1.已存在的虚拟机打开错误,可能是版本不一样的问题,我5.2.16版本,原虚拟机所属版本为4.3.12,换回4.3.12版本virtual box即可.
- [清华集训2017]榕树之心[树dp]
题意 题目链接 分析 首先解决 \(subtask3\) ,我们的策略就是进入子树,然后用其它子树来抵消,注意在子树内还可以抵消. 可以转化为此模型:有一个数列 \(a\) ,每次我们可以选定两个值 ...
- .net core实践系列之短信服务-Sikiro.SMS.Bus服务的实现
前言 前两篇<.net core实践系列之短信服务-Sikiro.SMS.Api服务的实现>.<.net core实践系列之短信服务-Api的SDK的实现与测试>分别讲解了AP ...
- 实例解析forEach、for...in与for...of
在开发过程中经常需要循环遍历数组或者对象,js也为我们提供了不少方法供使用,其中就有三兄弟forEach.for...in.for...of,这三个方法应该是使用频率最高的,但很多人却一值傻傻分不清, ...
- eclipse添加maven环境
一.打开eclipse,选择Window->preference,如下图所示 二.Maven-> installation->add,见下图: 三.选择Directory,选择mav ...
- C. Banh-mi
链接 [http://codeforces.com/contest/1062/problem/C] 题意 给你有n个字符(0 or 1)的串,当去某个位置时所有的剩下的位置都加上这个位置的数字,q次查 ...
- Linux实践:ELF文件格式分析
标签(空格分隔): 20135321余佳源 一.基础知识 ELF全称Executable and Linkable Format,可执行连接格式,ELF格式的文件用于存储Linux程序.ELF文件(目 ...