منتديات عالمي حلم

هل تريد التفاعل مع هذه المساهمة؟ كل ما عليك هو إنشاء حساب جديد ببضع خطوات أو تسجيل الدخول للمتابعة.

العالم المليئ بالأحلام

في منتديآت عالمي حلم تتحـقـق أحلامك

    WEEK 2 SHEET G FCIS division

    Admin
    Admin
    Admin


    عدد المساهمات : 412
    تاريخ التسجيل : 20/10/2010

    WEEK 2 SHEET G FCIS division  Empty WEEK 2 SHEET G FCIS division

    مُساهمة من طرف Admin الإثنين يناير 02, 2017 5:21 am

    الكود:
    #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;
    }
    Admin
    Admin
    Admin


    عدد المساهمات : 412
    تاريخ التسجيل : 20/10/2010

    WEEK 2 SHEET G FCIS division  Empty رد: WEEK 2 SHEET G FCIS division

    مُساهمة من طرف Admin الإثنين يناير 02, 2017 5:23 am

    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.
    Admin
    Admin
    Admin


    عدد المساهمات : 412
    تاريخ التسجيل : 20/10/2010

    WEEK 2 SHEET G FCIS division  Empty رد: WEEK 2 SHEET G FCIS division

    مُساهمة من طرف Admin الإثنين يناير 02, 2017 5:24 am

    Examples
    Input
    17
    Output
    LAB C
    Input
    18
    Output
    LAB B
    Input
    19
    Output
    LAB A

      الوقت/التاريخ الآن هو الثلاثاء مايو 07, 2024 2:42 pm