Codeforces Round #292 (Div. 2)
来源:互联网 发布:淘宝卖家诈骗800 编辑:程序博客网 时间:2024/05/22 10:57
Someday, Drazil wanted to go on date with Varda. Drazil and Varda live on Cartesian plane. Drazil's home is located in point (0,?0) and Varda's home is located in point (a,?b). In each step, he can move in a unit distance in horizontal or vertical direction. In other words, from position (x,?y) he can go to positions (x?+?1,?y), (x?-?1,?y), (x,?y?+?1) or (x,?y?-?1).
Unfortunately, Drazil doesn't have sense of direction. So he randomly chooses the direction he will go to in each step. He may accidentally return back to his house during his travel. Drazil may even not notice that he has arrived to (a,?b) and continue travelling.
Luckily, Drazil arrived to the position (a,?b) successfully. Drazil said to Varda: "It took me exactly s steps to travel from my house to yours". But Varda is confused about his words, she is not sure that it is possible to get from (0,?0) to (a,?b) in exactly s steps. Can you find out if it is possible for Varda?
You are given three integers a, b, and s (?-?109?≤?a,?b?≤?109, 1?≤?s?≤?2·109) in a single line.
If you think Drazil made a mistake and it is impossible to take exactly s steps and get from his home to Varda's home, print "No" (without quotes).
Otherwise, print "Yes".
5 5 11
No
10 15 25
Yes
0 5 1
No
0 0 2
Yes
In fourth sample case one possible route is: .
注意输入的坐标 可正可负#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<list>
#include<deque>
#include<map>
#include <stdio.h>
#include <queue>
#include <stack>
#define maxn 10000+5
#define ull unsigned long long
#define ll long long
#define reP(i,n) for(i=1;i<=n;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define cle(a) memset(a,0,sizeof(a))
#define mod 90001
#define PI 3.141592657
#define INF 1<<30
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
bool cmp(int a,int b)
{
return a>b;
}
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int a,b;
ll s;
cin>>a>>b;
if(a<0)a=-a;
if(b<0)b=-b;
cin>>s;
ll t=a+b-s;
if(t<=0)
{
t=-t;
if(t&1)cout<<"No"<<endl;
else cout<<"Yes"<<endl;
}
else cout<<"No"<<endl;
return 0;
}
Drazil has many friends. Some of them are happy and some of them are unhappy. Drazil wants to make all his friends become happy. So he invented the following plan.
There are n boys and m girls among his friends. Let's number them from 0 to n?-?1 and 0 to m?-?1 separately. In i-th day, Drazil invites -th boy and -th girl to have dinner together (as Drazil is programmer, i starts from 0). If one of those two people is happy, the other one will also become happy. Otherwise, those two people remain in their states. Once a person becomes happy (or if he/she was happy originally), he stays happy forever.
Drazil wants to know whether he can use this plan to make all his friends become happy at some moment.
The first line contains two integer n and m (1?≤?n,?m?≤?100).
The second line contains integer b (0?≤?b?≤?n), denoting the number of happy boys among friends of Drazil, and then follow b distinct integers x1,?x2,?...,?xb (0?≤?xi?<?n), denoting the list of indices of happy boys.
The third line conatins integer g (0?≤?g?≤?m), denoting the number of happy girls among friends of Drazil, and then follow g distinct integers y1,?y2,?... ,?yg (0?≤?yj?<?m), denoting the list of indices of happy girls.
It is guaranteed that there is at least one person that is unhappy among his friends.
If Drazil can make all his friends become happy by this plan, print "Yes". Otherwise, print "No".
2 3
0
1 0
Yes
2 4
1 0
1 2
No
2 3
1 0
1 1
Yes
By we define the remainder of integer division of i by k.
In first sample case:
- On the 0-th day, Drazil invites 0-th boy and 0-th girl. Because 0-th girl is happy at the beginning, 0-th boy become happy at this day.
- On the 1-st day, Drazil invites 1-st boy and 1-st girl. They are both unhappy, so nothing changes at this day.
- On the 2-nd day, Drazil invites 0-th boy and 2-nd girl. Because 0-th boy is already happy he makes 2-nd girl become happy at this day.
- On the 3-rd day, Drazil invites 1-st boy and 0-th girl. 0-th girl is happy, so she makes 1-st boy happy.
- On the 4-th day, Drazil invites 0-th boy and 1-st girl. 0-th boy is happy, so he makes the 1-st girl happy. So, all friends become happy at this moment.
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<list>
#include<deque>
#include<map>
#include <stdio.h>
#include <queue>
#include <stack>
#define maxn 10000+5
#define ull unsigned long long
#define ll long long
#define reP(i,n) for(i=1;i<=n;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define cle(a) memset(a,0,sizeof(a))
#define mod 90001
#define PI 3.141592657
#define INF 1<<30
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
bool cmp(int a,int b)
{
return a>b;
}
int a[110],b[110];
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout)
int n,m;
int x,y,t;
cle(a),cle(b);
cin>>n>>m;
cin>>x;
for(int i=0;i<x;i++)
{
cin>>t;
a[t]=1;
}
cin>>y;
for(int i=0;i<y;i++)
{
cin>>t;
b[t]=1;
}
int k=maxn;
for(int i=0;i<k;i++)
{
if(a[i%n]==0&&b[i%m]==0)continue;
a[i%n]=1;
b[i%m]=1;
}
int mark1=0,mark2=0;
for(int i=0;i<n;i++)
{
if(a[i]==0){mark1=1;break;}
}
for(int i=0;i<m;i++)
{
if(b[i]==0){mark2=1;break;}
}
if(mark1==0&&mark2==0)
cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}
Drazil is playing a math game with Varda.
Let's define for positive integer x as a product of factorials of its digits. For example, .
First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions:
1. x doesn't contain neither digit 0 nor digit 1.
2. = .
Help friends find such number.
The first line contains an integer n (1?≤?n?≤?15) — the number of digits in a.
The second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes.
Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation.
4
1234
33222
3
555
555
In the first case,
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<list>
#include<deque>
#include<map>
#include <stdio.h>
#include <queue>
#include <stack>
#define maxn 10000+5
#define ull unsigned long long
#define ll long long
#define reP(i,n) for(i=1;i<=n;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define cle(a) memset(a,0,sizeof(a))
#define mod 90001
#define PI 3.141592657
#define INF 1<<30
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
bool cmp(int a,int b)
{
return a>b;
}
//int a[10]={0,1,2,6,24,120,720,5040,40320,362880};
/*
4!=2!*2!*3!
6!=123456=5!*3!
8!=12345678=7!*2!*2!*2!
9!=123456789=7!*2!*3!*3!
*/
int a;
char s[40];
vector<int>v;
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int n;
cin>>n;
cin>>s;
for(int i=n-1;i>=0;i--)
{
a=(int)(s[i]-'0');
if(a==0||a==1)continue;
if(a==4)v.push_back(2),v.push_back(2),v.push_back(3);
else if(a==6) v.push_back(5),v.push_back(3);
else if(a==8)v.push_back(7),v.push_back(2),v.push_back(2),v.push_back(2);
else if(a==9)v.push_back(7),v.push_back(3),v.push_back(2),v.push_back(3);
else v.push_back(a);
}
sort(v.begin(),v.end());
for(int i=v.size()-1;i>=0;i--)
cout<<v[i];
cout<<endl;
return 0;
}
- Codeforces Round #292 (Div. 2)
- Codeforces Round #292 (Div. 2)。
- Codeforces Round #292 (Div. 2)
- Codeforces Round #292 (Div. 2)
- Codeforces Round #292 (Div. 2)
- Codeforces Round #292 (Div. 2)
- Codeforces Round #292 (Div. 2 Div. 1)
- Codeforces Round #292 (Div. 2) ABC
- Codeforces Round #292 (Div. 1)
- Codeforces Round #292 (Div. 1)
- Codeforces Round #102 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #104 (Div. 2)
- Codeforces Round #105 (Div. 2)
- Codeforces Round #105 (Div. 2)
- Codeforces Round #107 (Div. 2)
- Codeforces Round #108 (Div. 2)
- CF 293 A. Vitaly and Strings
- centos7 下双网卡如何配置静态IP
- Codeforces Round #295 (Div. 2)
- Codeforces Round #294 (Div. 2)
- Codeforces Round #293 (Div. 2)
- Codeforces Round #292 (Div. 2)
- IOS中NSUserDefaults的用法
- Codeforces Round #291 (Div. 2)
- HDU 2181 哈密顿绕行世界问题
- POJ 1426 Find The Multiple
- POJ 3984 迷宫问题
- HDU 2612 Find a way
- 字典树(trie 树)
- intellij idea15 破解