#10748. 数论第七题(NOIP2017)

数论第七题(NOIP2017)

第七题(NOIP2017)

#include<iostream>
using namespace std;
int main() {
    int n,m;
    cin>>n>>m;
    int x=1, y=1;
    int dx=1, dy=1;
    int cnt=0;
    while (cnt!=2) {
        cnt=0;
        x=x+dx;
        y=y+dy;
        if(x==1 || x==n) {
            ++cnt;
            dx=-dx;
        }
        if(y==1 || y==m) {
            ++cnt;
            dy=-dy;
        }
    }
    cout<<x<<" "<<y<<endl;
    return 0;
}
  1. 【判断题】若将16、20行去掉,则程序会出现死循环。
    {{ select(1) }}
  • 正确
  • 错误
  1. 【判断题】若将第一行的iostream改为cstdio,则程序会出现编译错误。
    {{ select(2) }}
  • 正确
  • 错误
  1. 【判断题】若将17、21行去掉,则程序会出现死循环。
    {{ select(3) }}
  • 正确
  • 错误
  1. 【判断题】记 L=min(n,m)L=min (n, m) ,则时间复杂度为 O(L2)O(L^{2})
    {{ select(4) }}
  • 正确
  • 错误
  1. 【选择题】输入2 3,则输出( )。
    {{ select(5) }}
  • 1 1
  • 2 2
  • 1 3
  • 3 1
  1. 【选择题】输入2 2,则输出( )。
    {{ select(6) }}
  • 1 1
  • 1 2
  • 2 1
  • 2 2