結果

問題 No.1092 modular arithmetic
ユーザー tails
提出日時 2020-11-02 15:04:02
言語 cLay
(20241019-1)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 438 bytes
コンパイル時間 3,136 ms
コンパイル使用メモリ 179,344 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-05 14:41:32
合計ジャッジ時間 4,554 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

{
	int a[100000];
	string s;
	int @p,@n;
	rd(a(n),s);
	if(p==2){
		int z=1;
		for(int i=0;i<n-1;++i){
			int op=s[i];
			z^=(op=='+')|(op=='-');
		}
		wt(z);
	}else{
		mint z;
		z.setmod(p);
		z=a[0];
		for(int i=0;i<n-1;){
			int op=s[i];
			++i;
			mint x=a[i];
			if(op=='/'){
				while(s[i]=='/'){
					++i;
					x*=a[i];
				}
				z/=x;
			}else{
				op=='+' ? z+=x :
				op=='-' ? z-=x :
				/**/      z*=x ;
			}
		}
		wt(z);
	}
}
0