Skip to content

Instantly share code, notes, and snippets.

@JanhaviDadhania
Created December 22, 2020 10:42
Show Gist options
  • Save JanhaviDadhania/8ed599e54aa7004cfa284a95da2d001a to your computer and use it in GitHub Desktop.
Save JanhaviDadhania/8ed599e54aa7004cfa284a95da2d001a to your computer and use it in GitHub Desktop.
#include "spoj_interactive.h"
#include <bits/stdc++.h>
#define MAX 500005
long long int a[MAX],n,cnt[MAX];
using namespace std;
void verdict_wrong(int i)
{
fprintf(spoj_for_tested,"%d\n",i);
spoj_assert(false);
}
void finalizeIT(int score)
{
fprintf(spoj_score, "%d", score);
}
int main()
{
spoj_init();
int hidden_no;
//read hidden no from input file
fscanf(spoj_p_in,"%d", &hidden_no);
fprintf(spoj_p_info,"Hidden No from input file is : %d\n",hidden_no);
//read from output file, whether the number is prime or not
int expected_out;
fscanf(spoj_p_out,"%d", &expected_out);
fprintf(spoj_p_info,"Expected output No. : %d\n", expected_out);
int n;
fscanf(spoj_t_out,"%d",&n);
while(n!=1 && n!=0 && n<=400) {
if(hidden_no % n == 0) {
fprintf(spoj_for_tested,"%s\n","YES");
}
else if(hidden_no % n != 0) {
fprintf(spoj_for_tested,"%s\n","NO");
}
fscanf(spoj_t_out,"%d",&n);
}
if(n == 1) {
if(expected_out == n) {
finalizeIT(1);
}
else {
verdict_wrong(-1);
}
}
else if(n == 0) {
if(expected_out == n) {
finalizeIT(1);
}
else {
verdict_wrong(-1);
}
}
else if(n > 400) {
verdict_wrong(-1);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment