Codeforces Round #313 (Div. 2) A B C 思路 枚举 数学
2 seconds
256 megabytes
standard input
standard output
A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum?
The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion.
The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes.
Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1.
5
1 2 3 4 5
-1 题意:给你n个数 可多次取任意组合并求和 令不能组成的数为 不幸运的数 问你最小的不幸运的数 若不存在输出-1
题解:可以发现若n个数中存在1则可以表示任何的数 否则不能表示的最小的数为-1
/*/******************************
code by drizzle
blog: www.cnblogs.com/hsd-/
^ ^ ^ ^
O O
******************************/
#include<bits/stdc++.h>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<bitset>
#include<math.h>
#include<vector>
#include<string>
#include<stdio.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int N=;
const int mod=;
const int MOD1=;
const int MOD2=;
const double EPS=0.00000001;
//typedef long long ll;
typedef __int64 ll;
const ll MOD=;
const int INF=;
const ll MAX=1ll<<;
const double eps=1e-;
const double inf=~0u>>;
const double pi=acos(-1.0);
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
int n;
int flag=;
int exm;
int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%d",&exm);
if(exm==)
flag=;
}
if(flag)
cout<<"-1"<<endl;
else
cout<<""<<endl; return ;
}
2 seconds
256 megabytes
standard input
standard output
Gerald bought two very rare paintings at the Sotheby's auction and he now wants to hang them on the wall. For that he bought a special board to attach it to the wall and place the paintings on the board. The board has shape of an a1 × b1 rectangle, the paintings have shape of a a2 × b2 and a3 × b3 rectangles.
Since the paintings are painted in the style of abstract art, it does not matter exactly how they will be rotated, but still, one side of both the board, and each of the paintings must be parallel to the floor. The paintings can touch each other and the edges of the board, but can not overlap or go beyond the edge of the board. Gerald asks whether it is possible to place the paintings on the board, or is the board he bought not large enough?
The first line contains two space-separated numbers a1 and b1 — the sides of the board. Next two lines contain numbers a2, b2, a3 and b3 — the sides of the paintings. All numbers ai, bi in the input are integers and fit into the range from 1 to 1000.
If the paintings can be placed on the wall, print "YES" (without the quotes), and if they cannot, print "NO" (without the quotes).
3 2
1 3
2 1
YES
5 5
3 3
3 3
NO
4 2
2 3
1 2
YES
That's how we can place the pictures in the first test:
And that's how we can do it in the third one.
题意:给你三个矩形的边长 判断第2,3个矩形能否放入第1个矩形
题解:很恶心的列举一下 以下一种精巧的代码
/*/******************************
code by drizzle
blog: www.cnblogs.com/hsd-/
^ ^ ^ ^
O O
******************************/
#include<bits/stdc++.h>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<bitset>
#include<math.h>
#include<vector>
#include<string>
#include<stdio.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
#define A first
#define B second
const int N=;
const int mod=;
const int MOD1=;
const int MOD2=;
const double EPS=0.00000001;
//typedef long long ll;
typedef __int64 ll;
const ll MOD=;
const int INF=;
const ll MAX=1ll<<;
const double eps=1e-;
const double inf=~0u>>;
const double pi=acos(-1.0);
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
int main(){
pair<int,int> a, b, c;
scanf("%d%d%d%d%d%d", &a.A, &a.B, &b.A, &b.B, &c.A, &c.B);
for(int k=;k<;k++,swap(a.A,a.B))
for(int i=;i<;i++,swap(b.A,b.B))
for(int j=;j<;j++,swap(c.A,c.B))
if (a.A>=max(b.A,c.A)&&a.B>=b.B+c.B){
puts("YES");
return ;
}
puts("NO");
return ;
}
2 seconds
256 megabytes
standard input
standard output
Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to . Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it.
He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles.
The first and the single line of the input contains 6 space-separated integers a1, a2, a3, a4, a5 and a6 (1 ≤ ai ≤ 1000) — the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists.
Print a single integer — the number of triangles with the sides of one 1 centimeter, into which the hexagon is split.
1 1 1 1 1 1
6
1 2 1 2 1 2
13
This is what Gerald's hexagon looks like in the first sample:
And that's what it looks like in the second sample:
题意:如图由正三角形组成的六边形 给你六条边的长度 输出三角形的个数
题解:先补全成一个大的正三角 之后剪去缺角
/*/******************************
code by drizzle
blog: www.cnblogs.com/hsd-/
^ ^ ^ ^
O O
******************************/
#include<bits/stdc++.h>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<bitset>
#include<math.h>
#include<vector>
#include<string>
#include<stdio.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int N=;
const int mod=;
const int MOD1=;
const int MOD2=;
const double EPS=0.00000001;
//typedef long long ll;
typedef __int64 ll;
const ll MOD=;
const int INF=;
const ll MAX=1ll<<;
const double eps=1e-;
const double inf=~0u>>;
const double pi=acos(-1.0);
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
int a1,a2,a3,a4,a5,a6;
int main()
{
scanf("%d %d %d %d %d %d",&a1,&a2,&a3,&a4,&a5,&a6);
int sum=a1+a2+a3;
int ans=sum+sum*(sum-);
int ans1=a1+a1*(a1-);
int ans2=(a3+a3*(a3-));
int ans3=(a5+a5*(a5-));
printf("%d\n",ans-ans1-ans2-ans3);
return ;
}
Codeforces Round #313 (Div. 2) A B C 思路 枚举 数学的更多相关文章
- Codeforces Round #313 (Div. 1)
官方英文题解:http://codeforces.com/blog/entry/19237 Problem A: 题目大意: 给出内角和均为120°的六边形的六条边长(均为正整数),求最多能划分成多少 ...
- dp - Codeforces Round #313 (Div. 1) C. Gerald and Giant Chess
Gerald and Giant Chess Problem's Link: http://codeforces.com/contest/559/problem/C Mean: 一个n*m的网格,让你 ...
- Codeforces Round #313 (Div. 1) B. Equivalent Strings
Equivalent Strings Problem's Link: http://codeforces.com/contest/559/problem/B Mean: 给定两个等长串s1,s2,判断 ...
- Codeforces Round #313 (Div. 1) A. Gerald's Hexagon
Gerald's Hexagon Problem's Link: http://codeforces.com/contest/559/problem/A Mean: 按顺时针顺序给出一个六边形的各边长 ...
- Codeforces Round #313 (Div. 2)B.B. Gerald is into Art
B. Gerald is into Art Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/ ...
- Codeforces Round #313 (Div. 2) D. Equivalent Strings
D. Equivalent Strings Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559/ ...
- Codeforces Round #313 (Div. 2) C. Gerald's Hexagon 数学
C. Gerald's Hexagon Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559/pr ...
- Codeforces Round #313 (Div. 2) A. Currency System in Geraldion
A. Currency System in Geraldion Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/co ...
- Codeforces Round #313 (Div. 2) E. Gerald and Giant Chess (Lucas + dp)
题目链接:http://codeforces.com/contest/560/problem/E 给你一个n*m的网格,有k个坏点,问你从(1,1)到(n,m)不经过坏点有多少条路径. 先把这些坏点排 ...
随机推荐
- Jquery API Hybrid APP调研
http://jquery.cuishifeng.cn/source.html hybrid app Hybrid App(混合模式移动应用)是指介于web-app.native-app这两者之间 ...
- LTP学习
下载LTP源码和模型文件: https://github.com/linux-test-project/ltp 官方说明文档 http://ltp.readthedocs.org/zh_CN/late ...
- SeGue 多控制器跨界面传递数据原理
多控制器跨界面传递数据原理
- c#读取文本文档实践2-计算商品价格
商品 数量 单价英语 66 100语文 66 80数学 66 100化学 66 40物理 66 60 上面是文本文档中读入的数据. using System; using System.Collect ...
- [安卓]AndroidManifest.xml文件简介及结构
1.AndroidManifest.xml文件简介: 每个应用程序在它的根目录中都必须要有一个AndroidManifest.xml(名字须精确一致)文件.这个清单把应用程序的基本信息提交给Andro ...
- office2013不能正常使用
感觉非常卡一样 还不能显示内容 工具栏也点不动 这个应该是Office硬件图形加速惹得祸,解决办法: 文件>选项>高级>显示,找到“禁用硬件图形加速”在前面打勾,关闭再打开就OK ...
- poj2392 多重背包
//Accepted 868 KB 188 ms //多重背包 #include <cstdio> #include <cstring> #include <iostre ...
- LIST 和 MAP
Collection和Map LIST 集合 arraylist arraylist源代码: 1.ArrayList 底层采用数组实现,当使用不带参数的构造方法生成 ArrayList 对象时,实际上 ...
- unity3d基础01
Unity3d 五大视图: 1 Scene:存放hierarchy中创建的游戏对象,但实际只能看到一部分 *Scene浏览: ①右键进入“飞行模式”,方便查看整个场景 ②选中摄像机,按ALT进入浏览的 ...
- mysql 创建存储过程注意
最近在利用navicat创建存储过程时,总是报1064语法错误,而且每次都是指向第一行,百思不得姐,如下图: 后来发现,原来是输入参数没有定义长度导致,所以以后真要注意 加上入参长度即可:IN `sT ...