- الكود:
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main()
{//(*it).first in map>>>
int a = 5 ,x,z=0,y=1,h=0,u,s=0,o;
cin>>x;
if (x==1)
cout<<"LAB B";
else
{ for (int i=2 ;i<x;i++)
{
if (x%i==0)
{
z=1;
break;
}
}
if (z==1)
cout<<"LAB B";
else //3613
{o=x;
for (int i=0;o!=0;i++)
{ u=o%10;
o=o/10;
s=(u+s)*10;
// y=y*10;
//cout<<" u "<<u<<endl<<"o "<<o<<endl;
}s=s/10;
if (s==x)
{
cout<<"LAB A";
}
else
{
for (int i=2 ;i<s;i++)
{
if (s%i==0)
{
h=1;
break;
}
}
if (h==0)
cout<<"LAB C" ;
else
cout<< "LAB A";
}
}}//cout<<"y "<<s;}
return 0;
}
مواضيع مماثلة
WEEK 2 SHEET G FCIS division
Admin- Admin
- عدد المساهمات : 413
تاريخ التسجيل : 20/10/2010
- مساهمة رقم 1
WEEK 2 SHEET G FCIS division
Admin- Admin
- عدد المساهمات : 413
تاريخ التسجيل : 20/10/2010
- مساهمة رقم 2
رد: WEEK 2 SHEET G FCIS division
G. FCIS division
time limit per test
2 seconds
memory limit per test
64 megabytes
input
standard input
output
standard output
People in FCIS want to divide the students into 3 labs. They wrote some numbers on papers, then every student withdraws a paper. A student would be in some lab depending on his number.
LAB A:
- If the number is prime and it’s reverse is not prime.
- If the number is prime and it equals its reverse.
LAB B:
- If the number is not prime.
LAB C:
- If the number and its reverse are primes and they are different (17 and 71).
Input
You will be given one number N(1 ≤ N ≤ 106) the number on the paper.
Output
You are asked to print "LAB A", "LAB B" or "LAB C" without the quotes depending on the number N.
time limit per test
2 seconds
memory limit per test
64 megabytes
input
standard input
output
standard output
People in FCIS want to divide the students into 3 labs. They wrote some numbers on papers, then every student withdraws a paper. A student would be in some lab depending on his number.
LAB A:
- If the number is prime and it’s reverse is not prime.
- If the number is prime and it equals its reverse.
LAB B:
- If the number is not prime.
LAB C:
- If the number and its reverse are primes and they are different (17 and 71).
Input
You will be given one number N(1 ≤ N ≤ 106) the number on the paper.
Output
You are asked to print "LAB A", "LAB B" or "LAB C" without the quotes depending on the number N.
Admin- Admin
- عدد المساهمات : 413
تاريخ التسجيل : 20/10/2010
- مساهمة رقم 3
رد: WEEK 2 SHEET G FCIS division
Examples
Input
17
Output
LAB C
Input
18
Output
LAB B
Input
19
Output
LAB A
Input
17
Output
LAB C
Input
18
Output
LAB B
Input
19
Output
LAB A