TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

小明寫了一個函式,可以用來玩剪刀石頭布,請你也寫一個函式,來跟他寫的函式來對決!
然而,他的程式碼不小心被你看到了!如下:

#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std;

int opponent(){
    int temp = rand() % 3;
    if (temp == 0) return 5; // 出布
    else if (temp == 1) return 2; // 出剪刀
    else return 0; // 出石頭
}

int you(int seed);
// 請完成 you() 函式。你的程式碼會被插在這裡。

bool win(int a, int b){
    if ((a == 5) and (b == 2)) return true; // 剪刀打贏布
    if ((a == 2) and (b == 0)) return true; // 石頭打贏剪刀
    if ((a == 0) and (b == 5)) return true; // 布打贏石頭
    return false;
}

int main() {
    int seed;
    cin >> seed;
    srand(seed);
    int a = opponent();
    int b = you(seed);
    if (win(a,b)) std::cout &lt;&lt; "You win!" &lt;&lt; std::endl;
    else std::cout &lt;&lt; "You lose!" &lt;&lt; std::endl;
    return 0;
}

在上面的程式中,opponent() 是小明寫的函式, you() 是你寫的函式,5 代表出布,2 代表出剪刀,0 代表出石頭。win() 會判斷你有沒有贏,如果你贏了,函式會回傳 true,如果沒贏,則會回傳 false。

請觀察上面的程式碼,想辦法完成 you() 函式,來讓 seed 不論給多少,你的函式都能夠打贏 opponent()!

Input Format

(你不需要處理輸入的問題)輸入會有一個整數,代表隨機種子。

$0\leq seed\leq 231 -1$

Output Format

(你不需要處理輸出的問題)如果你的函式打贏了對手,程式就會輸出 "You win!" 並換行。

Sample Input 1

0

Sample Output 1

You win!

Sample Input 2

2024

Sample Output 2

You win!

Sample Input 3

2147483647

Sample Output 3

You win!

Hints

Problem Source

NEOJ Problem 982

Subtasks

No. Testdata Range Constraints Score
1 0 10
2 1 10
3 2 10
4 3 10
5 4 10
6 5 10
7 6 10
8 7 10
9 8 10
10 9 10

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 65536 65536 1
1 1000 65536 65536 2
2 1000 65536 65536 3
3 1000 65536 65536 4
4 1000 65536 65536 5
5 1000 65536 65536 6
6 1000 65536 65536 7
7 1000 65536 65536 8
8 1000 65536 65536 9
9 1000 65536 65536 10