A. Currency System in Geraldion
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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?

Input

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.

Output

Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print  - 1.

Examples
Input
5
1 2 3 4 5
Output
-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 ;
}
B. Gerald is into Art
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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?

Input

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.

Output

If the paintings can be placed on the wall, print "YES" (without the quotes), and if they cannot, print "NO" (without the quotes).

Examples
Input
3 2
1 3
2 1
Output
YES
Input
5 5
3 3
3 3
Output
NO
Input
4 2
2 3
1 2
Output
YES
Note

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 ;
}
C. Gerald's Hexagon
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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.

Output

Print a single integer — the number of triangles with the sides of one 1 centimeter, into which the hexagon is split.

Examples
Input
1 1 1 1 1 1
Output
6
Input
1 2 1 2 1 2
Output
13
Note

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 思路 枚举 数学的更多相关文章

  1. Codeforces Round #313 (Div. 1)

    官方英文题解:http://codeforces.com/blog/entry/19237 Problem A: 题目大意: 给出内角和均为120°的六边形的六条边长(均为正整数),求最多能划分成多少 ...

  2. 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的网格,让你 ...

  3. Codeforces Round #313 (Div. 1) B. Equivalent Strings

    Equivalent Strings Problem's Link: http://codeforces.com/contest/559/problem/B Mean: 给定两个等长串s1,s2,判断 ...

  4. Codeforces Round #313 (Div. 1) A. Gerald's Hexagon

    Gerald's Hexagon Problem's Link: http://codeforces.com/contest/559/problem/A Mean: 按顺时针顺序给出一个六边形的各边长 ...

  5. 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/ ...

  6. Codeforces Round #313 (Div. 2) D. Equivalent Strings

    D. Equivalent Strings Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559/ ...

  7. 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 ...

  8. 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 ...

  9. 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)不经过坏点有多少条路径. 先把这些坏点排 ...

随机推荐

  1. Web体系=资源+URI+表示

    概述 Web有三个核心概念:资源(Resource).URI(UniformResource Identifer,统一资源标识符).表示(Representation).一个资源由一个URI进行标识. ...

  2. 【转】 JAR、WAR、EAR的使用和区别

    Jar.war.EAR.在文件结构上,三者并没有什么不同,它们都采用zip或jar档案文件压缩格式.但是它们的使用目的有所区别: Jar文件(扩展名为. Jar,Java Application Ar ...

  3. JAVA之关于super的用法

    JAVA之关于super的用法   路漫漫其修远兮,吾将上下而求索.——屈原<离骚> 昨天写this用法总结的时候,突然产生了一个问题,请教别人之后,有了自己的一点认识.还是把它写下来,为 ...

  4. 更改layout的布局

    创建了一个layout,缺省都是LinearLayout,原来都在xml把他改成其他布局,习惯了拖放的方式觉得挺麻烦. 其实vs2013有这个功能,就是在设计界面单机右键可以删除布局,然后拖一个布局进 ...

  5. Javascript 基础(一)

    一.Js命名规范(变量/函数) (1)使用大小写字母,数字,_ ,$ 可以命名 (2)不能以数字打头 (3)不能使用js的关键字/保留字 (4)区分大小写 (5)单行注释 //多行注释 二.js的数据 ...

  6. php无缝连接滚动

    最近用到了,仿照别人的写了一个 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "ht ...

  7. Linux下TC使用说明

    Linux下TC使用说明   一.TC原理介绍 Linux操作系统中的流量控制器TC(Traffic Control)用于Linux内核的流量控制,主要是通过在输出端口处建立一个队列来实现流量控制. ...

  8. BW增强数据源的两种方法

    BW增强数据源的两种方法 2009-04-01, by SAPBI 前言:我们经常会遇到系统标准的数据源,或者我们自建的数据源无法满足要求的情况,这个时候在数据源中添加几个相关的字段,可能就能满足我们 ...

  9. hdu 2082

    ps:get到了母函数...看了好久的模板与介绍....似懂非懂..决定要多找些题来试试... 代码: #include "stdio.h" #include "stri ...

  10. 为什么SQL语句加 1=1

    是为了链接下面的查询条件条件,也或者是替换没有查询条件的语句.比如:要把检索条件作为一个参数传递给SQL,那么,当这个检索语句不存在的话就可以给它赋值为1=1.这样就避免了SQL出错,也就可以把加条件 ...