Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
- #define int long long int
- #define forn(i,n) for(int i=0;i<n;i++)
- #define pb push_back
- #define ff first
- #define ss second
- const int M = 1e9 + 7;
- const int N = 9e7;
- bool sieve[N];
- void solve()
- {
- sieve[0] = sieve[1] = 1;
- for(int i = 2; i*i<=N; i++)
- {
- if(!sieve[i])
- {
- for(int j = i*i; j<N; j+=i )
- sieve[i] = 1;
- }
- }
- int t;
- cin>>t;
- while(t--)
- {
- string num;
- cin>>num;
- //cout<<num<<" ";
- int size = num.length();
- //cout<<num;
- // cout<<size<<" ";
- int x = stoi(num);
- //cout<<x<<" ";
- if(!sieve[x])
- {
- cout<<"yes\n";
- break;
- }
- /* if(num == 1000000)
- {
- cout<<"no\n";
- break;
- }
- */
- int cnt = 0;
- for(int j = 1; j<=9; j++)
- {
- num[0] = (char)j;
- x = stoi(num);
- if(!sieve[x])
- {
- cnt++;
- }
- }
- for(int i = 1; i<size; i++)
- {
- for(int j = 0; j<=9; j++)
- {
- num[i] = (char)j;
- x = stoi(num);
- if(!sieve[x])
- {
- cnt++;
- }
- }
- }
- if(cnt == 1)
- cout<<"yes\n";
- else
- cout<<"no\n";
- }
- return;
- }
- signed main()
- { IOS
- solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement