Ural State University Internal Contest October'2000 Junior Session
POJ 上的一套水题,哈哈~~~,最后一题很恶心,不想写了~~~
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 7410 | Accepted: 2603 |
Description

Your task is to find out a length of the rope.
Input
Output
Sample Input
4 1
0.0 0.0
2.0 0.0
2.0 2.0
0.0 2.0
Sample Output
14.28
Source
#include <bits/stdc++.h> using namespace std; #define PI acos(-1) const int maxn = ; struct Node {
double x,y;
}nodes[maxn]; double dist (int i,int j) {
double tx = nodes[i].x - nodes[j].x;
double ty = nodes[i].y - nodes[j].y;
return sqrt(tx*tx+ty*ty);
} int main()
{
int n;
double r;
scanf("%d%lf",&n,&r); for(int i = ; i < n; i++) {
scanf("%lf%lf",&nodes[i].x,&nodes[i].y);
} double ans = ; for(int i = ; i < n; i++) {
ans+= dist(i,(i+)%n);
} ans+= PI**r;
printf("%.2f\n",ans); return ;
}
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 2508 | Accepted: 1115 |
Description
— Tsh-sh-sh! This is madness that borders on blasphemy! How can the Machine calculate the Sacred Number? Twenty seven years we work on it, but we've could teach it to tell if the sum of two introduced numbers greater or lower than 10 000. Can an ordinary mortal find two numbers that there sum will be equal to 10 000?
— But we'll have to do it with the help of our Machine, even if it is not capable. Otherwise we'll have... let's say, big problems, if it is possible to call boiling oil like this. However, I have an idea. Do you remember, last week we've entered two numbers -7 and 13 into the Machine, and it answered that their sum is lower than 10 000. I don't know how to check this, but nothing's left for us than to believe to the fruit of our work. Let's enter now a greater number than -7 and start up the Machine again. We'll do like this again and again until we find a number that being added to 13 will give us 10 000. The only thing we are to do is to prepare an ascending list of numbers.
— I don't believe in this... Let's start with the sum that is obviously greater than the Sacred Number and we'll decrease one of the summand. So we have more chances to avoid boilin... big problems.
Haven't come to an agreement, the Brothers went away to their cells. By next day everyone of them has prepared a list of numbers that, to his opinion, could save them... Can both of the lists save them together?
Your program should decide, if it is possible to choose from two lists of integers such two numbers that their sum would be equal to 10 000.
Input
Output
Sample Input
4
-175
19
19
10424
3
8951
-424
-788
Sample Output
YES
Hint
Source
#include <bits/stdc++.h> using namespace std; int main()
{
int n,m;
scanf("%d",&n);
set<int> s; for(int i = ; i < n; i++) {
int x;
scanf("%d",&x);
s.insert(x);
} scanf("%d",&m); bool flag = false;
for(int i = ; i < m; i++) {
int y;
scanf("%d",&y);
y = - y;
if(s.count(y)) flag = true; } if(flag)
puts("YES");
else puts("NO"); return ;
}
Time Limit: 1000MS | Memory Limit: 65536K | |||
Total Submissions: 6171 | Accepted: 4073 | Special Judge |
Description
And in the Planetary Council the confusing genealogical system leads to some embarrassment. There meet the worthiest of Martians, and therefore in order to offend nobody in all of the discussions it is used first to give the floor to the old Martians, than to the younger ones and only than to the most young childless assessors. However, the maintenance of this order really is not a trivial task. Not always Martian knows all of his parents (and there's nothing to tell about his grandparents!). But if by a mistake first speak a grandson and only than his young appearing great-grandfather, this is a real scandal.
Your task is to write a program, which would define once and for all, an order that would guarantee that every member of the Council takes the floor earlier than each of his descendants.
Input
Output
Sample Input
5
0
4 5 1 0
1 0
5 3 0
3 0
Sample Output
2 4 5 3 1
Source
#include <bits/stdc++.h> using namespace std; const int maxn = ;
int c[maxn];
int topo[maxn],t;
bool G[maxn][maxn];
int n;
bool dfs(int u) {
c[u] = -;
for(int v = ; v < n; v++) if(G[u][v]) {
if(c[v]<) return false;
else if(!c[v]&&!dfs(v)) return false;
}
c[u] = ;
topo[--t] = u;
return true;
} bool toposort() {
t = n;
memset(c,,sizeof(c));
for(int u = ; u < n; u++) if(!c[u])
if(!dfs(u)) return false;
return true;
} int main()
{
scanf("%d",&n);
for(int i = ; i < n; i++) {
int x;
while() {
scanf("%d",&x);
if(x==) break;
x--;
G[i][x] = ;
}
} toposort();
for(int i = ; i < n; i++) printf("%d ",topo[i]+);
puts(""); return ;
}
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 3892 | Accepted: 1082 |
Description
The rules of the game are very simple. There's a small heap of K buttons before two players. The players in turns take buttons from the heap, moreover, at a time one can take a number of buttons from 1 up to L. The one who takes the last button is the winner.
The rules of the Olympic Games will be a bit harder then usual. The one, who is to make a first step according to a lot, has an opportunity to fix a number K with the following restriction to it: 3 <= K <= 100 000 000 (that is the exact number of buttons that has been prepared for the Olympic tournament). The player who is to make the second step fixes a number L that satisfies the following conditions 2 <= L < K.
A very crucial task is given to your team: you are to write a program that should help the second player to make his choice. In other words, given a number K your program is to find a number L that guaranties a victory to the second player with a proper game of both sides.
So, for instance, there are only three buttons in the heap, the choice L = 2 provides for the victory of the second player. Really, if the first player takes only one button at his turn, the second one wins, taking the two last buttons. On the contrary, if the first one takes two buttons, the second one wins, taking the last button.
Input
Output
Sample Input
3
Sample Output
2
Source
#include <bits/stdc++.h> using namespace std; int main()
{
int n;
scanf("%d",&n);
for(int m = ; m < n; m++) {
if(n%(m+)==)
{
printf("%d\n",m);
break;
}
} return ;
}
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 3281 | Accepted: 1780 |
Description

This record defines a permutation P as follows: P(1) = 4, P(2) = 1, P(3) = 5, etc.
What is the value of the expression P(P(1))? It’s clear, that P(P(1)) = P(4) = 2. And P(P(3)) = P(5) = 3. One can easily see that if P(n) is a permutation then P(P(n)) is a permutation as well. In our example (believe us)

It is natural to denote this permutation by P2(n) = P(P(n)). In a general form the defenition is as follows: P(n) = P1(n), Pk(n) = P(Pk-1(n)). Among the permutations there is a very important one — that moves nothing:

It is clear that for every k the following relation is satisfied: (EN)k = EN. The following less trivial statement is correct (we won't prove it here, you may prove it yourself incidentally): Let P(n) be some permutation of an N elements set. Then there exists a natural number k, that Pk = EN. The least natural k such that Pk = EN is called an order of the permutation P.
The problem that your program should solve is formulated now in a very simple manner: "Given a permutation find its order."
Input
Output
Sample Input
5
4 1 5 2 3
Sample Output
6
Source
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <algorithm> using namespace std; const int maxn = ;
int a[maxn]; int gcd(int a,int b) {
return b == ? a : gcd(b,a%b);
} int lcm(int a,int b) {
return a/gcd(a,b)*b;
} int main()
{
int n;
scanf("%d",&n); for(int i = ; i <= n; i++) scanf("%d",&a[i]); vector<int> v;
for(int i = ; i <= n; i++) { int cnt = ;
int pos = i;
while(true) {
if(a[pos]==i) break;
pos = a[pos];
cnt++;
}
v.push_back(cnt);
} int ans = ;
for(int i = ; i < (int)v.size(); i++)
ans = lcm(ans,v[i]);
cout<<ans<<endl; return ;
}
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 3442 | Accepted: 2553 |
Description
The essence of the reform is as follows. From the moment of its coming into effect all the citizens were divided into K (may be not equal) groups. Votes on every question were to be held then in each group, moreover, the group was said to vote "for" if more than half of the group had voted "for", otherwise it was said to vote "against". After the voting in each group a number of group that had voted "for" and "against" was calculated. The answer to the question was positive if the number of groups that had voted "for" was greater than the half of the general number of groups.
At first the inhabitants of the island accepted this system with pleasure. But when the first delights dispersed, some negative properties became obvious. It appeared that supporters of the party, that had introduced this system, could influence upon formation of groups of voters. Due to this they had an opportunity to put into effect some decisions without a majority of voters "for" it.
Let's consider three groups of voters, containing 5, 5 and 7 persons, respectively. Then it is enough for the party to have only three supporters in each of the first two groups. So it would be able to put into effect a decision with the help of only six votes "for" instead of nine, that would .be necessary in the case of general votes.
You are to write a program, which would determine according to the given partition of the electors the minimal number of supporters of the party, sufficient for putting into effect of any decision, with some distribution of those supporters among the groups.
Input
Output
Sample Input
3
5 7 5
Sample Output
6
Source
#include <bits/stdc++.h> using namespace std; const int maxn = ;
int a[maxn]; int main()
{
int k;
scanf("%d",&k); for(int i = ; i <= k; i++) scanf("%d",&a[i]);
sort(a+,a++k); int ans = ;
for(int i = ; i <= (k+)/; i++)
ans+=(a[i]+)/;
printf("%d\n",ans); return ;
}
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 11511 | Accepted: 6087 |
Description
Your program is to play a role of a controller of the database. In the other words, it should be able to process quickly queries like this.
Input
Output
Sample Input
5
7
121
123
7
121
###
4
3
3
2
5
Sample Output
121
121
7
123
Source
#include <bits/stdc++.h> using namespace std; const int maxn = ;
int a[maxn]; int main()
{
int n,k;
scanf("%d",&n); for(int i = ; i<=n; i++) {
scanf("%d",&a[i]);
} sort(a+,a+n+); char st[];
scanf("%s",st);
scanf("%d",&k); for(int i = ; i < k; i++) {
int x;
scanf("%d",&x);
printf("%d\n",a[x]);
} return ;
}
Ural State University Internal Contest October'2000 Junior Session的更多相关文章
- URAL 1208 Legendary Teams Contest(DFS)
Legendary Teams Contest Time limit: 1.0 secondMemory limit: 64 MB Nothing makes as old as years. A l ...
- zoj 4020 The 18th Zhejiang University Programming Contest Sponsored by TuSimple - G Traffic Light(广搜)
题目链接:The 18th Zhejiang University Programming Contest Sponsored by TuSimple - G Traffic Light 题解: 题意 ...
- The 18th Zhejiang University Programming Contest Sponsored by TuSimple
Pretty Matrix Time Limit: 1 Second Memory Limit: 65536 KB DreamGrid's birthday is coming. As hi ...
- The 16th Zhejiang University Programming Contest-
Handshakes Time Limit: 2 Seconds Memory Limit: 65536 KB Last week, n students participated in t ...
- 152 - - G Traffic Light 搜索(The 18th Zhejiang University Programming Contest Sponsored by TuSimple )
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5738 题意 给你一个map 每个格子里有一个红绿灯,用0,1表示 ...
- 写完代码就去吃饺子|The 10th Henan Polytechnic University Programming Contest
河南理工大学第十届校赛 很久没有组队打比赛了,好吧应该说很久没有写题了, 三个人一起玩果然比一个人玩有趣多了... 前100分钟过了4题,中途挂机100分钟也不知道什么原因,可能是因为到饭点太饿了?, ...
- ural 1208 Legendary Teams Contest
题意描述:给定K支队伍,每队三个队员,不同队伍之间队员可能部分重复,输出这些队员同时能够组成多少完整的队伍: DFS,利用DFS深度优先搜索,如果该队所有队员都没有被访问过,那么将该队计入结果,再去选 ...
- The 15th Zhejiang University Programming Contest
a ZOJ 3860 求和大家不一样的那个数,签到,map水之 #include<cstdio> #include<map> using namespace std; map ...
- ZOJ3865:Superbot(BFS) The 15th Zhejiang University Programming Contest
一个有几个小坑的bfs 题目很长,但并不复杂,大概总结起来有这么点. 有t组输入 每组输入n, m, p.表示一个n*m的地图,每p秒按键会右移一次(这个等会儿再讲). 然后是地图的输入.其中'@'为 ...
随机推荐
- $bzoj1052-HAOI2007$ 覆盖问题 抽屉原理 二分答案
题面描述 某人在山上种了\(N\leq 2*10^4\)棵小树苗.冬天来了,温度急速下降,小树苗脆弱得不堪一击,于是树主人想用一些塑料薄膜把这些小树遮盖起来,经过一番长久的思考,他决定用\(3\) ...
- Python(xlrd、xlwt模块)操作Excel实例(一)
一.前言 关于Python的xlrd.xlwt模块的使用,推介另一位博客主的博文:https://www.cnblogs.com/zhoujie/p/python18.html 这篇里面有详细介绍这两 ...
- (转)CentOS6/7 使用saltstack源安装saltstack
CentOS6/7 使用saltstack源安装saltstack 原文:https://blog.csdn.net/wh211212/article/details/77053708 CentOS ...
- (转)详解Linux中SSH远程访问控制
详解Linux中SSH远程访问控制 原文:http://blog.51cto.com/dengqi/1260038 SSH:是一种安全通道协议,主要用来实现字符界面的远程登录,远程复制等功能(使用TC ...
- springsource-tool-suite下载(sts)
1 新版本的插件下载 1 直接进入官网下载即可 官网地址:http://spring.io/tools/sts/all. 2 spring官网上下载历史版本的spring插件 1 获取新版本的插件的地 ...
- java 中String编码和byte 解码总结——字节流和字符流
1.InputStreamReader 是字节流通向字符流的桥梁:它使用指定的 charset 读取字节并将其解码为字符 InputStreamReader(InputStream in, Strin ...
- intent 活动之间穿梭
1.从当前activity,跳转到当前应用程序的activity Intent intent = new Intent(MainActivity.this, Intent2Activity.class ...
- 转载:.NET Memory Leak: XmlSerializing your way to a Memory Leak
原文地址:http://blogs.msdn.com/b/tess/archive/2006/02/15/532804.aspx I hate to give away the resolution ...
- linux shell之for循环
两种方式 第一种 for((i=1;i<10;i++)) do echo $i done 第二种 for i in {1..10} do echo $i done
- ssh命令使用
ssh是什么 ssh是一种通信协议,用于与另一台计算机通信,有多个实现版本,openssh属于开源实现 usage: ssh [-B bind_interface] [-b bind_address] ...