Bestcoder (with Rice!) )
|
The Drunk JailerTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others) Total submission (s): 1397 Accepted Submission (s): 1127
Problem Descriptiona Certain prison contains a long hall of n cells, each of which is next to the other. Each cell had a prisoner in it, and each cell was locked. One night, the jailer gets bored and decides to play a game. For Round 1 of the game, he takes a drink of whiskey, and then runs to the hall unlocking each cell. For Round 2, he takes a drink of whiskey, and then runs to the hall locking every other cell (cells 2, 4, 6, ...). For Round 3, he takes a drink of whiskey, and then runs down the hall. He visits every third cell (cells 3, 6, 9, ...). If the cell is locked, he unlocks it; If it is unlocked, he locks it. He repeats this for n rounds, takes a final drink, and passes out.
Some number of prisoners, possibly zero, realizes that their cells was unlocked and the jailer is incapacitated. They immediately escape.
Given the number of cells, determine how many prisoners escape jail.
Inputthe first line of input contains a single positive integer. This is the number of lines that follow. Each of the following lines contains a single integer between 5 and over, inclusive, which is the number of cells N. Outputfor each line, you must print out the number of prisoners that escape when the prison have n cells. Sample INPUT2 5 100 Sample Output2 10 |
Problem: Similar to switching lights, the most water ...
Code:
1#include <stdio.h>2#include <string.h>3 intmap[ the];4 intMain () {5 intT,n;6scanf"%d",&T);7 while(t--){8memset (Map,0,sizeof(map));9scanf"%d",&N);Ten for(intI=2; i<=n;i++){ One for(intj=1; j<=n;j++){ A if(j%i==0){ - if(Map[j]) map[j]=0; - Elsemap[j]=1; the } - } - } - intnum=0; + for(intI=1; i<=n;i++){ - if(!map[i]) num++; + } Aprintf"%d\n", num); at } - return 0; -}
Count the Colors Time limit: 2 Seconds Memory Limit: 65536 KB
Painting some colored segments on a line, some previously painted segments could be covered by some the subsequent ones.
Your task is counting the segments of different colors you can see at last.
Input
The first line of all data set contains exactly one integer n, 1 <= n <= 8000, equal to the number of colored Segme Nts.
Each of the following n lines consists of exactly 3 nonnegative integers separated by single spaces:
X1 X2 C
X1 and X2 indicate the left endpoint and right endpoint of the segment, C indicates the color of the segment.
All the numbers is in the range [0, 8000], and they is all integers.
Input may contain several data set, and process to the end of file.
Output
Each line of the output should contain a color index this can be seen from the top, following the count of the segments of This color, they should is printed according to the color index.
If some color can ' t is seen, you shouldn ' t print it.
Print a blank line after every dataset.
Sample Input
5
0 4 4
0 3 1
3 4 2
0 2 2
0 2 3
4
0 1 1
3 4 1
1 3 2
1 3 1
6
0 1 0
1 2 1
2 3 1
1 2 0
2 3 0
1 2 1
Sample Output
1 1
2 1
3 1
1 1
0 2
1 1
Problem: Test instructions really not very good to understand; this question means a dash, give n sets of data, each group gives three values, the first two points represent the starting point and the end point, the third point represents the color of the dash, and the overlay of the painting is drawn first.
I am using two arrays, one array of the color of the storage edge, the other array, the number of segments of different color segments;
Code:
1#include <stdio.h>2#include <algorithm>3#include <string.h>4 using namespacestd;5 Const intmaxn=8010;6 intS[MAXN],E[MAXN];7 intMain () {8 intn,a,b,c;9 while(~SCANF ("%d",&N)) {Tenmemset (s,-1,sizeof(s)); OneMemset (E,0,sizeof(e)); A for(intI=0; i<n;i++){ -scanf"%d%d%d",&a,&b,&c); - for(inti=a+1; i<=b;i++) s[i]=C; the } - //for (int i=0;i<5;i++) printf ("%d", S[i]);p UTS (""); - for(intI=1; i<=8000; i++){ - if(s[i-1]!=s[i]&&s[i]!=-1) e[s[i]]++; + } - for(intI=0; i<=8000; i++){ + if(E[i]) { Aprintf"%d%d\n", I,e[i]); at } - } -Puts""); - } - return 0; -}
Four School leagues