提出 #73512565


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    ll m, a, b; 
    cin >> m >> a >> b;
    
    ll res = 0;
    
    for(ll x = 1; x < m; x++){
        for(ll y = 1; y < m; y++){
            set<pair<ll,ll>> seen;  // Track PAIRS!
            
            ll s1 = x, s2 = y;
            bool valid = true;
            
            for(int iter = 0; iter < m*m; iter++){  // Max m^2 states
                if(seen.count({s1, s2})){
                    // Cycle without hitting 0
                    break;
                }
                seen.insert({s1, s2});
                
                ll next = (a * s2 + b * s1) % m;
                
                if(next == 0){
                    valid = false;
                    break;
                }
                
                s1 = s2;
                s2 = next;
            }
            
            if(valid) res++;
        }
    }
    
    cout << res << '\n';
}

提出情報

提出日時
問題 E - Multiple-Free Sequences
ユーザ mg00s
言語 C++ IOI-Style(GNU++20) (GCC 14.2.0)
得点 0
コード長 1003 Byte
結果 TLE
実行時間 > 2000 ms
メモリ 2348 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 450
結果
AC × 2
TLE × 1
AC × 21
TLE × 15
セット名 テストケース
Sample 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt
All 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt, 01-31.txt, 01-32.txt, 01-33.txt
ケース名 結果 実行時間 メモリ
00-sample-01.txt AC 0 ms 1580 KiB
00-sample-02.txt TLE > 2000 ms 1580 KiB
00-sample-03.txt AC 435 ms 1580 KiB
01-01.txt AC 0 ms 1580 KiB
01-02.txt AC 0 ms 1580 KiB
01-03.txt AC 0 ms 1580 KiB
01-04.txt AC 0 ms 1580 KiB
01-05.txt AC 11 ms 1580 KiB
01-06.txt AC 24 ms 1580 KiB
01-07.txt TLE > 2000 ms 1708 KiB
01-08.txt TLE > 2000 ms 1708 KiB
01-09.txt TLE > 2000 ms 1708 KiB
01-10.txt TLE > 2000 ms 1580 KiB
01-11.txt AC 207 ms 1580 KiB
01-12.txt TLE > 2000 ms 1580 KiB
01-13.txt AC 18 ms 1580 KiB
01-14.txt AC 44 ms 1580 KiB
01-15.txt AC 48 ms 1580 KiB
01-16.txt AC 501 ms 1580 KiB
01-17.txt AC 24 ms 1580 KiB
01-18.txt AC 26 ms 1580 KiB
01-19.txt AC 362 ms 1580 KiB
01-20.txt AC 209 ms 1580 KiB
01-21.txt AC 70 ms 1604 KiB
01-22.txt AC 113 ms 1580 KiB
01-23.txt AC 649 ms 1580 KiB
01-24.txt AC 704 ms 1580 KiB
01-25.txt TLE > 2000 ms 1604 KiB
01-26.txt TLE > 2000 ms 2348 KiB
01-27.txt TLE > 2000 ms 1708 KiB
01-28.txt TLE > 2000 ms 1708 KiB
01-29.txt TLE > 2000 ms 1580 KiB
01-30.txt TLE > 2000 ms 1836 KiB
01-31.txt TLE > 2000 ms 1708 KiB
01-32.txt TLE > 2000 ms 1580 KiB
01-33.txt TLE > 2000 ms 1580 KiB