建议加强数据,模拟即可水过
查看原帖
建议加强数据,模拟即可水过
1074084
asd890123楼主2024/6/8 19:35

rt,code:

#include <iostream>
#include <map>

int main(){
    
    std::ios::sync_with_stdio(0);
    std::cin.tie(0),std::cout.tie(0);
    
    int T,p,x,y,rounds;
    
    std::cin >> T >> p;
    while (T--){
        
        std::map <std::pair<int,int>,bool> vis;
        
        rounds = 0;
        std::cin >> x >> y;
        while (x && y){
            
            rounds++;
            if (rounds % 2 == 1) x = (x + y) % p;
            else y = (x + y) % p;
            if (vis[{x,y}]){
                
                std::cout << "error\n";
                break;
                
            }
            vis[{x,y}] = true;
            
        }
        if (x == 0) std::cout << "1\n";
        else if (y == 0) std::cout << "2\n";
        
    }
    
    return 0;
}
2024/6/8 19:35
加载中...