Submission #3587161


Source Code Expand

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
long gcd(long x, long y);
int main(void){
  long n,m,i,x,y,g=0;
  scanf("%ld %ld", &n, &m);
  if(n<m){
    i=n;
    n=m;
    m=i;
    g=1;
  }
  char s[n], t[m];
  if(g==1){
   scanf("%s", t);
   scanf("%s",s);
  }
  else {
   scanf("%s", s);
   scanf("%s", t);
  }
  g = gcd(n,m);
  x = n/g;
  y = m/g;
  for(i=0; m > y*i && n > x*i; i++){
     
    if(*(s+x*i)==*(t+y*i)); 
    else{
     x=1;
     y=1;
     g=-1;
     break;
     }
   }
  printf("%ld",x*y*g);
  return 0;
}
long gcd(long x, long y){
	return y==0 ? x:gcd(y,x % y);
}

Submission Info

Submission Time
Task A - Two Abbreviations
User Nocks_on
Language C (GCC 5.4.1)
Score 0
Code Size 632 Byte
Status WA
Exec Time 1 ms
Memory 384 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:7:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%ld %ld", &n, &m);
   ^
./Main.c:16:4: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
    scanf("%s", t);
    ^
./Main.c:17:4: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
    scanf("%s",s);
    ^
./Main.c:20:4: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
    scanf("%s", s);
    ^
./Main.c:21:4: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
    scanf("%s", t);
    ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 3
AC × 20
WA × 1
Set Name Test Cases
Sample sample-01.txt, sample-02.txt, sample-03.txt
All sample-01.txt, sample-02.txt, sample-03.txt, sample-01.txt, sample-02.txt, sample-03.txt, subtask01-01.txt, subtask01-02.txt, subtask01-03.txt, subtask01-04.txt, subtask01-05.txt, subtask01-06.txt, subtask01-07.txt, subtask01-08.txt, subtask01-09.txt, subtask01-10.txt, subtask01-11.txt, subtask01-12.txt, subtask01-13.txt, subtask01-14.txt, subtask01-15.txt
Case Name Status Exec Time Memory
sample-01.txt AC 1 ms 128 KB
sample-02.txt AC 1 ms 128 KB
sample-03.txt AC 0 ms 128 KB
subtask01-01.txt AC 1 ms 128 KB
subtask01-02.txt AC 1 ms 256 KB
subtask01-03.txt AC 1 ms 256 KB
subtask01-04.txt AC 1 ms 256 KB
subtask01-05.txt AC 1 ms 256 KB
subtask01-06.txt AC 1 ms 256 KB
subtask01-07.txt AC 1 ms 256 KB
subtask01-08.txt AC 1 ms 256 KB
subtask01-09.txt AC 1 ms 256 KB
subtask01-10.txt AC 1 ms 384 KB
subtask01-11.txt AC 1 ms 256 KB
subtask01-12.txt WA 1 ms 256 KB
subtask01-13.txt AC 1 ms 256 KB
subtask01-14.txt AC 1 ms 256 KB
subtask01-15.txt AC 1 ms 256 KB