Submission #1439029


Source Code Expand

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#define N 10005
#define INF 111111
using namespace std;

int a[105],b[105];
long long ans=0;

inline long long read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int main(){
	int i;
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	n=read();
	for(i=0;i<n;i++){
		a[i]=read();
		b[i]=read();
	}
    for(i=n-1;i+1;i--) 
		ans=ans+(b[i]-(a[i]+ans)%b[i])%b[i];
    	//ans=b[i]-(a[i]+ans);
		//ans=ans%b[i];
		//ans=ans+(ans%b[i]);
	printf("%lld\n",ans);
	//while(1);
	return 0;
} 

Submission Info

Submission Time
Task A - Multiple Array
User Malkavian
Language C++14 (GCC 5.4.1)
Score 0
Code Size 749 Byte
Status RE
Exec Time 96 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 2
AC × 4
RE × 14
Set Name Test Cases
Sample s1.txt, s2.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt RE 95 ms 256 KB
02.txt RE 95 ms 256 KB
03.txt RE 94 ms 256 KB
04.txt RE 95 ms 256 KB
05.txt RE 95 ms 256 KB
06.txt RE 95 ms 256 KB
07.txt RE 95 ms 256 KB
08.txt RE 95 ms 256 KB
09.txt RE 96 ms 256 KB
10.txt RE 95 ms 256 KB
11.txt RE 95 ms 256 KB
12.txt RE 95 ms 256 KB
13.txt RE 95 ms 256 KB
14.txt RE 96 ms 256 KB
15.txt AC 1 ms 256 KB
16.txt AC 1 ms 256 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB