結果

問題 No.2649 [Cherry 6th Tune C] Anthem Flower
ユーザー 沙耶花沙耶花
提出日時 2024-02-23 21:32:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 704 ms / 2,000 ms
コード長 1,077 bytes
コンパイル時間 4,640 ms
コンパイル使用メモリ 264,872 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-23 21:32:41
合計ジャッジ時間 11,001 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 505 ms
6,676 KB
testcase_02 AC 507 ms
6,676 KB
testcase_03 AC 532 ms
6,676 KB
testcase_04 AC 501 ms
6,676 KB
testcase_05 AC 704 ms
6,676 KB
testcase_06 AC 681 ms
6,676 KB
testcase_07 AC 36 ms
6,676 KB
testcase_08 AC 35 ms
6,676 KB
testcase_09 AC 8 ms
6,676 KB
testcase_10 AC 8 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 27 ms
6,676 KB
testcase_14 AC 28 ms
6,676 KB
testcase_15 AC 27 ms
6,676 KB
testcase_16 AC 27 ms
6,676 KB
testcase_17 AC 27 ms
6,676 KB
testcase_18 AC 27 ms
6,676 KB
testcase_19 AC 27 ms
6,676 KB
testcase_20 AC 27 ms
6,676 KB
testcase_21 AC 28 ms
6,676 KB
testcase_22 AC 27 ms
6,676 KB
testcase_23 AC 28 ms
6,676 KB
testcase_24 AC 28 ms
6,676 KB
testcase_25 AC 28 ms
6,676 KB
testcase_26 AC 28 ms
6,676 KB
testcase_27 AC 28 ms
6,676 KB
testcase_28 AC 27 ms
6,676 KB
testcase_29 AC 28 ms
6,676 KB
testcase_30 AC 28 ms
6,676 KB
testcase_31 AC 28 ms
6,676 KB
testcase_32 AC 28 ms
6,676 KB
testcase_33 AC 28 ms
6,676 KB
testcase_34 AC 458 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001
string get(string S){
	reverse(S.begin(),S.end());
	string ret = "";
	int carry = 1;
	rep(i,S.size()){
		int t = S[i]-'0' + carry;
		if(t>=10)carry = 1;
		else carry = 0;
		t %= 10;
		ret += '0'+t;
	}
	if(carry)ret += "1";
	reverse(ret.begin(),ret.end());
	return ret;
	
}
string Get(string S){
	string ret = "";
	int carry = 0;
	rep(i,S.size()){
		int t = carry*10;
		t += S[i] - '0';
		ret += '0' + (t/2);
		carry = t%2;
	}
	return ret;
}

int main(){
	
	int _t;
	cin>>_t;
	rep(_,_t){
		string N;
		cin>>N;
		
		long long M;
		cin>>M;
		
		string N2 = get(N);
		if((N.back()-'0')%2==0)N = Get(N);
		else N2 = Get(N2);
		
		long long X = 0,Y = 0;
		rep(i,N.size()){
			X *= 10;
			X += N[i]-'0';
			X %= M;
		}
		rep(i,N2.size()){
			Y *= 10;
			Y += N2[i]-'0';
			Y %= M;
		}
		X *= Y;
		cout<<X%M<<endl;
		
	}
	
	return 0;
}
0