hdu1792 水题

最近转到vim上来了,用vim编写代码,用gcc编译,用gdb调试。这是用vim做的第一道题,纪念下。题目很水,就不说了。

/*
 * Author    : ben
 */
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <functional>
#include <numeric>
#include <cctype>
using namespace std;

int getB(int a, int b, int A) {
    int B = 0;
    while(A > 0) {
        B += A / a + 1;
        A -= b;
    }
    return B - 1;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("data.in", "r", stdin);
#endif
    int a, b;
    int A, B;
    while(scanf("%d %d", &a, &b) == 2) {
        if(a > b) {
            a = a ^ b;
            b = a ^ b;
            a = a ^ b;
        }
        A = (a - 1) * (b - 1) - 1;
        B = getB(a, b, A);
        B = A - B;
        printf("%d %d\n", A, B);
    }
    return 0;
}

 

posted @ 2013-11-05 19:53  moonbay  阅读(180)  评论(0)    收藏  举报