CodeForces 560A,B,C
来源:互联网 发布:数据核查计划 编辑:程序博客网 时间:2024/04/29 16:18
CodeForces 560A
题意:给定一个货币系统,问不能组成的最小的钱数是多少。
思路:水,只要检查有没有出现1即可,有则输出-1,否则1.
code:
#include <iostream>#include <cstdio>#include <cmath>#include <algorithm>#include <cstring>#include <sstream>#include <string>#include <vector>#include <list>#include <queue>#include <stack>#include <map>#include <set>#include <bitset>using namespace std;typedef long long ll;typedef unsigned long long ull;typedef long double ld;const int INF=0x3fffffff;const int inf=-INF;const int N=1000000+5;const int M=1e3+5;const int mod=1000000007;const double pi=acos(-1.0);#define cls(x,c) memset(x,c,sizeof(x))#define cpy(x,a) memcpy(x,a,sizeof(a))#define ft(i,s,n) for (int i=s;i<=n;i++)#define frt(i,s,n) for (int i=s;i>=n;i--)#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define lrt rt<<1#define rrt rt<<1|1#define middle int m=(r+l)>>1#define lowbit(x) (x&-x)#define pii pair<int,int>#define mk make_pair#define IN freopen("in.txt","r",stdin);#define OUT freopen("out.txt","w",stdout);int v[M],vis[N];int main(){ int n;cls(vis,0); scanf("%d",&n); ft(i,1,n) scanf("%d",&v[i]),vis[v[i]]=1; sort(v+1,v+1+n); if (v[1]==1) puts("-1"); else puts("1");}
题意:给定一个相框,问能否把两张照片放进去。。
思路:依旧水,对于两个照片,只有长长,短短,长短和短长这四种放法,没swap会wa??
code:
#include <iostream>#include <cstdio>#include <cmath>#include <algorithm>#include <cstring>#include <sstream>#include <string>#include <vector>#include <list>#include <queue>#include <stack>#include <map>#include <set>#include <bitset>using namespace std;typedef long long ll;typedef unsigned long long ull;typedef long double ld;const int INF=0x3fffffff;const int inf=-INF;const int N=1000000;const int M=2005;const int mod=1000000007;const double pi=acos(-1.0);#define cls(x,c) memset(x,c,sizeof(x))#define cpy(x,a) memcpy(x,a,sizeof(a))#define ft(i,s,n) for (int i=s;i<=n;i++)#define frt(i,s,n) for (int i=s;i>=n;i--)#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define lrt rt<<1#define rrt rt<<1|1#define middle int m=(r+l)>>1#define lowbit(x) (x&-x)#define pii pair<int,int>#define mk make_pair#define IN freopen("in.txt","r",stdin);#define OUT freopen("out.txt","w",stdout);int a[5],b[5];bool ok(){ int s1,s2; s1=max(b[3],b[2]); s2=a[3]+a[2]; if (s1>s2) swap(s1,s2); if (s1<=a[1]&&s2<=b[1]) return 1; s1=max(a[3],a[2]); s2=b[3]+b[2]; if (s1>s2) swap(s1,s2); if (s1<=a[1]&&s2<=b[1]) return 1; s1=max(b[3],a[2]); s2=a[3]+b[2]; if (s1>s2) swap(s1,s2); if (s1<=a[1]&&s2<=b[1]) return 1; s1=max(a[3],b[2]); s2=b[3]+a[2]; if (s1>s2) swap(s1,s2); if (s1<=a[1]&&s2<=b[1]) return 1; return 0;}int main(){ ft(i,1,3) { scanf("%d %d",&a[i],&b[i]); if (a[i]>b[i]) swap(a[i],b[i]); } if(ok()) puts("YES"); else puts("NO");}
CodeForces 560C
题意:给定一个六边形的各边长度,已知相邻两边夹角均为120度,求能分成多少变长为1的正三角形。
思路:分别延长v2,v4,v6得到一个大的正三角形,用两个边的平方表示正三角形面积(多乘了2/根号3),然后减去多补的那部分。
code:
#include <iostream>#include <cstdio>#include <cmath>#include <algorithm>#include <cstring>#include <sstream>#include <string>#include <vector>#include <list>#include <queue>#include <stack>#include <map>#include <set>#include <bitset>using namespace std;typedef long long ll;typedef unsigned long long ull;typedef long double ld;const int INF=0x3fffffff;const int inf=-INF;const int N=1000000+5;const int M=1e5+5;const int mod=1000000007;const double pi=acos(-1.0);#define cls(x,c) memset(x,c,sizeof(x))#define cpy(x,a) memcpy(x,a,sizeof(a))#define ft(i,s,n) for (int i=s;i<=n;i++)#define frt(i,s,n) for (int i=s;i>=n;i--)#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define lrt rt<<1#define rrt rt<<1|1#define middle int m=(r+l)>>1#define lowbit(x) (x&-x)#define pii pair<int,int>#define mk make_pair#define IN freopen("in.txt","r",stdin);#define OUT freopen("out.txt","w",stdout);int v[8];int main(){ ft(i,1,6) scanf("%d",&v[i]); int s=(v[1]+v[2]+v[3])*(v[1]+v[2]+v[3])-v[1]*v[1]-v[3]*v[3]-v[5]*v[5]; printf("%d\n",s);}
0 0
- CodeForces 560A,B,C
- codeforces 282 A B C
- Codeforces 300-A/B/C
- CodeForces 572A,B,C
- CodeForces 707-A,B,C
- Codeforces 371 A,B,C
- Codeforces Beta Round #1 A B C
- CodeForces#211(Div.2) - A,B,C
- Codeforces Beta Round #1 A B C
- Codeforces Beta Round #2 A B C
- Codeforces 228 div2 A,B,C
- Codeforces Round #231 A,B,C
- codeforces 239 (div2) A B C D
- codeforces 208(div2) A+B+C+D
- Codeforces Rounds #254 div2:A,B,C
- codeforces 260 div2 A,B,C
- Codeforces Round #278(Div2) A B C
- codeforces #285 div2 *A B *C
- Go语言 使用Sublime Text 3搭建Go的开发环境(windows)
- Strongswan5.3.3与Android5.0.2(小米) 主模式的对接L2TPoverIPsec
- 最全Pycharm教程(30)——Pycharm中的File Watchers
- easyui自动换行
- 你应该知道的9个优秀的CSS框架
- CodeForces 560A,B,C
- joomla 1.5-3.4 Remote Code Execution (exp)
- C++有哪几种情况只能用初始化列表,而不能用赋值?http://zhidao.baidu.com/link?url=omVOhkgo4ZtpRddk794ly-aX79VjboKv3c3noM5tdz
- Strongswan5.3.5与Android5.0.2(小米)野蛮模式的L2TPoverIPsec的对接
- JMeter学习(一)工具简单介绍
- 学习新东西的基本套路
- 图像识别,ocr 技术,有兴趣的可以了解一下
- Android中TextView控件的跑马灯效果实现
- Xsolla与Hi-Rez工作室合作,发展游戏Paladins: Champions of the Realm