水题(找规律)

Posted nonames

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了水题(找规律)相关的知识,希望对你有一定的参考价值。

http://codeforces.com/gym/101061/problem/A

A. Cards
time limit per test
2.0 s
memory limit per test
64 MB
input
standard input
output
standard output

Omar has a deck of cards. Every card has a unique integer number written on it. He says that his cards are numbered starting from 1, and if a card with number N exists, then a card with number N + 1 exists. Yes he may have an infinite sequence !

Yesterday when he went to school, his little brother Samir played with his cards by sorting them into two boxes according to the numbers written on them by repeating the following two steps:

  1. Take the card with the smallest number, let it be X.
  2. Put the card with number X in the first box and put the card with number 2 * X in the second box.
So the first few numbers in the boxes will be:

First box : 1, 3, 4, 5, 7, ...

Second box : 2, 6, 8, 10, 14, ...

Omar came back home and he asked Samir for the card with number Q written on it. Help Samir to find out in which box he can find the required card.

Input

Your program will be tested on one or more test cases. The first line of the input will be a single integer T, the number of test cases .

T lines follow, each describing a test case consisting of a single integer Q (1 ≤ Q ≤ 1018)

Output

For every test case print "First Box" if the card is in the first box or "Second Box" otherwise.

Example
Input
Copy
3
1
6
1024
Output
Copy
First Box
Second Box
First Box
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <vector>
#include <map>
#define ME(x , y) memset(x , y , sizeof(x))
#define SF(n) scanf("%d" , &n)
#define rep(i , n) for(int i = 0 ; i < n ; i ++)
#define INF  0x3f3f3f3f
#define mod 1000000007
using namespace std;
typedef long long ll ;



int main()

    int t ;
    scanf("%d" , &t);
    while(t--)
    
        ll n , ans = 0 ;
        scanf("%lld" , &n);
        if(n % 2 == 1)
        
            printf("First Box\n");
        
        else
        
            while(n % 2 == 0)
            
                n /= 2 ;
                ans ++ ;
            
            if(ans % 2 == 1)
                printf("Second Box\n");
            else
                printf("First Box\n");
        

    

    return 0 ;

 

以上是关于水题(找规律)的主要内容,如果未能解决你的问题,请参考以下文章

长春理工大学第十四届程序设计竞赛F Successione di Fixoracci——找规律&&水题

ACM_同余+暴力找规律

Python找规律_01

[找规律] aw3636. 数组延伸(数学+思维+找规律)

SGU 169 Numbers (找规律)

比赛题解 更新ING