結果

問題 No.988 N×Mマス計算(総和)
ユーザー idat_50meidat_50me
提出日時 2020-03-30 12:21:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 2,760 bytes
コンパイル時間 1,558 ms
コンパイル使用メモリ 166,832 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-20 12:20:06
合計ジャッジ時間 3,173 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 22 ms
4,380 KB
testcase_11 AC 35 ms
4,376 KB
testcase_12 AC 57 ms
4,376 KB
testcase_13 AC 28 ms
4,380 KB
testcase_14 AC 26 ms
4,376 KB
testcase_15 AC 23 ms
4,380 KB
testcase_16 AC 47 ms
4,376 KB
testcase_17 AC 59 ms
4,380 KB
testcase_18 AC 33 ms
4,376 KB
testcase_19 AC 54 ms
4,376 KB
testcase_20 AC 80 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘ll GreaterBinarySearch(ll*, ll, ll, ll)’ 内:
main.cpp:95:24: 警告: NULL から非ポインタ型 ‘ll’ {aka ‘long long int’} へ変換しています [-Wconversion-null]
   95 |                 return NULL;
      |                        ^~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define PI 3.141592653589793
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define INTINF 1<<30
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) { //階乗
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) { //素数判定
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll wari=1LL;
	while(n/wari) {
		digit++;
		wari*=10;
	}
	return digit;
}

void PrimeFact(ll x) { // 素因数分解 出力部を適切に書き換え
	int i=2;
	while(x%2&&i*i<=x) {
		cout<<2<<endl;
		x/=2;
	}
	i++;
	while(i*i<=x) {
		if(x%i) {
			i+=2;
			continue;
		}
		cout<<i<<endl;
		x/=i;
	}
}

bool Palind(string s) { //回文判定
	return s == string(s.rbegin(), s.rend());
}

struct Node{
	vector<int> next;
	int prev;
	ll cnt;
};

int main() {
	int N,M,K; cin>>N>>M>>K;
	char op; cin>>op;
	int A[N],B[M];
	ll asum=0LL, bsum=0LL;
	for(int i=0; i<M; i++) {
		cin>>B[i];
		bsum+=B[i];
	}
	for(int i=0; i<N; i++) {
		cin>>A[i];
		asum+=A[i];
	}
	asum%=K;
	bsum%=K;

	ll sum=0LL;
	if(op=='+') {
		sum+=asum*M;
		sum+=bsum*N;
		sum%=K;
		cout<<sum<<endl;
	}
	else {
		sum=asum*bsum;
		sum%=K;
		cout<<sum<<endl;
	}
}
0