Codeforces 811 A Vladik and Courtesy

来源:互联网 发布:ubuntu des 解密 编辑:程序博客网 时间:2024/05/21 14:07

题目地址:http://codeforces.com/contest/811/problem/A
题解:就是直接模拟就好了,减的个数依次递增直到减不了,输出对应的字符串

#include <iostream>#include <cstring>#include <string>#include <vector>#include <queue>#include <map>#include <algorithm>#define N 100010#define inf 0x3f3f3f3f#define LL long longusing namespace std;const LL mod = 1e9 + 7;int main() {    cin.sync_with_stdio(false);    int a, b;    while (cin >> a >> b) {        int ans=1;        int flag = 1;        while (a >= ans) {            flag = 2;            a -= ans;            ans++;            if (b < ans) {                break;            }            b -= ans;            ans++;            flag = 1;        }        if (flag == 1) {            cout << "Vladik" << endl;        }        else {            cout << "Valera" << endl;        }    }    return 0;}