• 四校联赛


    The Drunk Jailer

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 1397    Accepted Submission(s): 1127


    Problem Description
    A certain prison contains a long hall of n cells, each right next to each other. Each cell has a prisoner in it, and each cell is 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 down the hall unlocking each cell. For round 2, he takes a drink of whiskey, and then runs down 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 are unlocked and the jailer is incapacitated. They immediately escape.

    Given the number of cells, determine how many prisoners escape jail.
     

    Input
    The 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 100, inclusive, which is the number of cells n.
     

    Output
    For each line, you must print out the number of prisoners that escape when the prison has n cells.
     

    Sample Input
    2 5 100
     

    Sample Output
    2 10

     题解:类似于开关灯的问题,最水的一道题。。。

    代码:

     1 #include<stdio.h>
     2 #include<string.h>
     3 int map[110];
     4 int main(){
     5     int T,N;
     6     scanf("%d",&T);
     7     while(T--){
     8         memset(map,0,sizeof(map));
     9         scanf("%d",&N);
    10         for(int i=2;i<=N;i++){
    11             for(int j=1;j<=N;j++){
    12                 if(j%i==0){
    13                     if(map[j])map[j]=0;
    14                     else map[j]=1;
    15                 }
    16             }
    17         }
    18         int num=0;
    19         for(int i=1;i<=N;i++){
    20             if(!map[i])num++;
    21         }
    22         printf("%d
    ",num);
    23     }
    24     return 0;
    25 }
    Count the Colors

    Time Limit: 2 Seconds      Memory Limit: 65536 KB

    Painting some colored segments on a line, some previously painted segments may 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 each data set contains exactly one integer n, 1 <= n <= 8000, equal to the number of colored segments.

    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 are in the range [0, 8000], and they are all integers.

    Input may contain several data set, process to the end of file.


    Output

    Each line of the output should contain a color index that can be seen from the top, following the count of the segments of this color, they should be printed according to the color index.

    If some color can't be 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

    题解:题意真的不太好理解;这道题意思是划线,给N组数据,每组给三个值,前两个点代表起点和终点,第三个点代表划线的颜色,后画的覆盖先画的。

    我是用两个数组,一个数组存边的颜色,另一个数组存,不同颜色段的段数;

    代码:

     1 #include<stdio.h>
     2 #include<algorithm>
     3 #include<string.h>
     4 using namespace std;
     5 const int MAXN=8010;
     6 int s[MAXN],e[MAXN];
     7 int main(){
     8     int n,a,b,c;
     9     while(~scanf("%d",&n)){
    10         memset(s,-1,sizeof(s));
    11         memset(e,0,sizeof(e));
    12         for(int i=0;i<n;i++){
    13             scanf("%d%d%d",&a,&b,&c);
    14             for(int i=a+1;i<=b;i++)s[i]=c;
    15         }
    16         //for(int i=0;i<5;i++)printf("%d ",s[i]);puts("");
    17         for(int i=1;i<=8000;i++){
    18             if(s[i-1]!=s[i]&&s[i]!=-1)e[s[i]]++;
    19         }
    20         for(int i=0;i<=8000;i++){
    21             if(e[i]){
    22                 printf("%d %d
    ",i,e[i]);
    23             }
    24         }
    25         puts("");
    26     }
    27     return 0;
    28 }
  • 相关阅读:
    XSS--PHPwind5.3复现
    网络基础一
    不老的神器--namp,awvs
    苏醒的巨人----CSRF
    XSS--编码绕过,qcms,鲶鱼cms
    XSS----payload,绕过,xss小游戏记录
    sql注入--高权限,load_file读写文件
    提权基础-----mysql-udf提权
    weblogic AND jboss 反序列化漏洞
    简单的压力测试工具 siege
  • 原文地址:https://www.cnblogs.com/handsomecui/p/4743491.html
Copyright © 2020-2023  润新知