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秒按键会右移一次(这个等会儿再讲). 然后是地图的输入.其中'@'为 ...
随机推荐
- $bzoj1009-HNOI2008$ $GT$考试 字符串$dp$ 矩阵快速幂
题面描述 阿申准备报名参加\(GT\)考试,准考证号为\(N\)位数\(x_1,x_2,...,x_n\ (0\leq x_i\leq 9)\),他不希望准考证号上出现不吉利的数字. 他的不吉利数字\ ...
- Python 中数据的序列化和反序列化(json处理)
概念: JSON(JavaScript Object Notation):是一种轻量级的数据交换格式. 易于人阅读和编写.同时也易于机器解析和生成. 它基于JavaScript Programming ...
- 分享:JAVA和C# 3DES加密解密
最近 一个项目.net 要调用JAVA的WEB SERVICE,数据采用3DES加密,涉及到两种语言3DES一致性的问题,下面分享一下,这里的KEY采用Base64编码,便用分发,因为Java的Byt ...
- 02-struts2结果常见的四种处理方式
1 转发 <!--转发 --> <action name="Demo1Action" class="www.test.a_result.Demo1Act ...
- CentOS 6.5 安装MySQL数据库
CentOS 6.5 安装MySQL数据库 [root@seeker~]# yum -y install mysql-server //安装命令 [root@seeker~]# service mys ...
- Redis启动和关闭
带配置文件启动 ./redis-server redis.conf 关闭 无密码模式 ./redis-cli -h xxx -p xxx shutdown 密码模式 ./redis-cli -h ...
- 数组和json的相互转换
json_encode() <?php /*****一维数组*********/ //有键 $arr = array( 'a'=>1, 'b'=>2, 'c'=>3, ); $ ...
- Linux文本处理工具
Linux文本处理工具 Linux中熟练的使用文本处理工具非常的重要, 因为Linux在设计的时候是采用一切皆文件的哲学的, 甚至连计算机中的配置也都使用伪文件系统来表示, 要查询里面的内容就是对文件 ...
- 净推荐值(NPS):用户忠诚度测量的基本原理及方法
文章分享了一个衡量用户与产品或服务之间关系的指标:NPS,干货满满,希望对你有益. 初识NPS 作为互联网行业的用户体验从业者,我们都或多或少会接触一些衡量用户与产品或服务之间关系的指标,常见的指标如 ...
- 浅谈前端与SEO
转载地址: https://blog.csdn.net/lzm18064126848/article/details/53385274?tdsourcetag=s_pctim_aiomsg SEO(S ...