Submission #3711403


Source Code Expand

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#define llong long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))




int main(void)
{
	//変数の宣言
	int q;
	llong int a[110];
	llong int b[110];
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	llong int ans=0;
	int count=0;
	int sum=0;
	long int temp,temp1,temp2;
	int max,min;
	int len;
	//データの読み込み
	
	scanf("%d",&q);
	
	for(i=0;i<q;i++){
		scanf("%lld %lld",&a[i],&b[i]);
	}
	
//	for(i=0;i<q;i++){
//		printf("%lld %lld\n",a[i],b[i]);
//	}
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	for(i=0;i<q;i++){
//		printf("i=%d q=%d\n",i,q);
		if(a[i]==b[i]){
			printf("%lld\n",2*a[i]-2);
		}else if(abs(a[i]-b[i])==1){
			printf("%lld\n",a[i]+b[i]-3);
		}else{
			temp=(long int)sqrt(a[i]*b[i]);
			if(temp*(temp+1)<a[i]*b[i]){
				printf("%ld\n",temp*2-1);
			}else if(temp*(temp+1)==a[i]*b[i]){
				printf("%ld\n",temp*2-2);
			}else if(temp*temp==a[i]*b[i]){
				printf("%ld\n",temp*2-3);
			}else{
				printf("%ld\n",temp*2-2);
			}
		}
	}
//	printf("計算部分終了\n");
	//出力
	
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}

Submission Info

Submission Time
Task D - Worst Case
User rausumaru
Language C (GCC 5.4.1)
Score 700
Code Size 1311 Byte
Status AC
Exec Time 1 ms
Memory 128 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:32:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&q);
  ^
./Main.c:35:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld",&a[i],&b[i]);
   ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 1
AC × 12
Set Name Test Cases
Sample s1.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, s1.txt
Case Name Status Exec Time Memory
01.txt AC 1 ms 128 KB
02.txt AC 1 ms 128 KB
03.txt AC 1 ms 128 KB
04.txt AC 1 ms 128 KB
05.txt AC 1 ms 128 KB
06.txt AC 1 ms 128 KB
07.txt AC 1 ms 128 KB
08.txt AC 1 ms 128 KB
09.txt AC 1 ms 128 KB
10.txt AC 1 ms 128 KB
11.txt AC 1 ms 128 KB
s1.txt AC 1 ms 128 KB