Sicily 4427. Greatest Common Divisors

来源:互联网 发布:沈阳网络营销黑马网络 编辑:程序博客网 时间:2024/05/18 03:00

新手赛正赛的热身题,看到时间给出5sec,觉得可能很容易超时,但数据跨度最大又只有1000,就有点弄糊涂了。最后决定暴力试下,结果居然0sec就过了,连scanf都用不上……

Run Time: 0sec

Run Memory: 312KB

Code length: 453Bytes

Submit Time: 2011-12-27 21:19:04

// Problem#: 4427// Submission#: 1138598// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/// All Copyright reserved by Informatic Lab of Sun Yat-sen University#include <iostream>using namespace std;int main(){    int T;    int a, b;    int low, high;    int i;    cin >> T;    while ( T-- ) {        cin >> a >> b >> low >> high;        for ( i = high; i >= low; i-- ) {            if ( a % i == 0 && b % i == 0 )                break;        }        if ( i >= low )            cout << i << endl;        else            cout << "No answer\n";    }    return 0;}