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秒按键会右移一次(这个等会儿再讲). 然后是地图的输入.其中'@'为 ...
随机推荐
- TCP协议三次握手、四次挥手过程
本文通过图来梳理TCP-IP协议相关知识.TCP通信过程包括三个步骤:建立TCP连接通道,传输数据,断开TCP连接通道.如图1所示,给出了TCP通信过程的示意图. 上图主要包括三部分:建立连接.传输数 ...
- 发送请求时params和data的区别
在使用axios时,注意到配置选项中包含params和data两者,以为他们是相同的,实则不然. 因为params是添加到url的请求字符串中的,用于get请求. 而data是添加到请求体(body) ...
- 牛客网Java刷题知识点之equals和hashcode()
不多说,直接上干货! 福利 => 每天都推送 欢迎大家,关注微信扫码并加入我的4个微信公众号: 大数据躺过的坑 Java从入门到架构师 人工智能躺过的坑 ...
- vi编辑器备忘录
1. 基本操作 G 移动到文件最后一行 nG 移动到n行 gg 移动到第一行 N[Enter] 向下移动n行 /word 向下寻找 ?word 向上寻找 n 查找下一个 N 查找上一个 0或者Home ...
- JQuery实现表格的全选和反选,以及分页勾选保存(laypage插件分页的使用)
需求: 1.全选与取消全选 2.单个勾选,点击表格单元格中checkbox勾选,也可以在点击行勾选,便与用户操作 3.分页勾选保存 4.固定表头 功能一: 说明:操作全选按钮的同时,遍历每一个tr中的 ...
- vim创建新的命令
转自:http://man.chinaunix.net/newsoft/vi/doc/usr_5F40.html#usr_40.txt *40.1* 键映射 简单的映射已经在 |05.3| 介绍过了. ...
- JS之this那些事
一直以来,对this的讨论都是热门话题.有人说掌握了this就掌握了JavaScript的80%,说法有点夸张,但可见this的重要性.至今记录了很多关于this的零碎笔记,今天就来个小结. 本人看过 ...
- 如何设计一个“高大上”的 logo
前不久,我们老大写的一篇博客< Coding,做一个有情怀的产品 >中有提到设计 Coding logo 的大致由来,今天我就设计 Coding 猴头的过程具体说说如何设计一个 logo. ...
- RequireJS 2.0 正式发布
就在前天晚上RequireJS发布了一个大版本,直接从version1.0.8升级到了2.0.随后的几小时James Burke又迅速的将版本调整为2.0.1,当然其配套的打包压缩工具r.js也同时升 ...
- 插入排序——Java实现
一.排序思想 从数组第一个元素开始(0下标),该元素可以认为已经被排序: 取出待排序列中第一个元素,然后从“有序”序列中,从后往前扫描: 如果该元素(有序序列)大于待插入元素(待排序列),将该元素后移 ...