結果

問題 No.3015 アンチローリングハッシュ
ユーザー i_am_nicolen_22i_am_nicolen_22
提出日時 2019-08-16 01:17:20
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,269 bytes
コンパイル時間 1,431 ms
コンパイル使用メモリ 163,928 KB
実行使用メモリ 6,368 KB
最終ジャッジ日時 2023-10-19 19:43:03
合計ジャッジ時間 14,769 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
4,348 KB
testcase_01 AC 176 ms
4,348 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 528 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using ull = unsigned long long;
vector<ll>rolling_hash_search(string s,string t){
    vector<long long >index_list;
    ll SL=s.size();
    ll TL=t.size();

    ull b=1e8+7;
    ull a=1;
    for (int i = 0; i < TL; i++)
    {
        a*=b;
    }
    ull s_hash = 0;
    for (int i = 0; i < TL; i++)
    {
        s_hash=s_hash*b+s[i];
    }
    ull t_hash=0;
    for (int i = 0; i < TL; i++)
    {
        t_hash=t_hash*b+t[i];
    }
    for (int i = 0; i < SL-TL+1; i++)
    {
        if(s_hash==t_hash) index_list.push_back(i);
        if(i+TL<SL) s_hash=s_hash*b-s[i]*a+s[i+TL];
    }
    return index_list;
}

int main(){
  int a,b;
  cin>>a>>b;
  string s,t;
  ll cnt=0;
  int d=0;
  for (int i = 1; i <=25; i++)
  {     
      cnt=0;
      ll copy=a;
      bool flag=false;
      while(1){
        if(cnt>1e6) break;
         copy*=copy;
         copy%=b;
        if((copy*i)%b==0) {
            flag=true;
            d=i;
            break;
        }
       
        cnt++;
      }
      if(flag) break;
  }
  s.push_back('a');
  t.push_back('a'+d);
  for (int i = 0; i < cnt; i++)
  {
      s.push_back('a');
      t.push_back('a');
  }
  
  cout<<s<<endl;
  cout<<t<<endl;
    return 0;
}

0