├── README.md └── Week 2 solutions ├── CRDGAME3 ├── Perfect Permutation ├── addndiv.cpp └── special_triplets.cpp /README.md: -------------------------------------------------------------------------------- 1 | # IEEE-Coding-WC-2022 2 | Welcome to IEEE-SBM-Coding-Domain, head over to [wiki](https://github.com/adityachandra1/IEEE-Coding-WC-2022/wiki) and start learning :) 3 | 4 | -------------------------------------------------------------------------------- /Week 2 solutions/CRDGAME3: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int t,x,y,res1,res2; 6 | cin>>t; 7 | while(t--){ 8 | cin>>x>>y; 9 | res1=x/9+1; 10 | if(x%9==0) 11 | res1--; 12 | res2=y/9+1; 13 | if(y%9==0) 14 | res2--; 15 | if(res1 2 | using namespace std; 3 | #define ll long long int 4 | int main(){ 5 | int t; 6 | cin>>t; 7 | while(t--){ 8 | ll a,b,fl=0,g; 9 | cin>>a>>b; 10 | while(!fl){ 11 | g=__gcd(a,b); 12 | a=a/g; 13 | if(a==1){ 14 | fl=1; 15 | break; 16 | } 17 | if(g==1){ 18 | break; 19 | } 20 | } 21 | if(fl) 22 | cout<<"YES"<<"\n"; 23 | else 24 | cout<<"NO"<<"\n"; 25 | } 26 | return 0; 27 | } -------------------------------------------------------------------------------- /Week 2 solutions/special_triplets.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace __gnu_pbds; 4 | using namespace std; 5 | 6 | const int m7 = 1e9 + 7; 7 | const int m9 = 1e9 + 9; 8 | #define l(x, n) for(int x = 0; x < n; ++x) 9 | #define l2(x, a, b) for(int x = a; x <= b; ++x) 10 | #define rl(x, a, b) for(int x = a; x >=b; --x) 11 | #define ll long long 12 | #define li long int 13 | #define ulli unsigned long long int 14 | #define fio ios::sync_with_stdio(0);cin.tie(0); 15 | #define F first 16 | #define S second 17 | #define PB push_back 18 | #define MP make_pair 19 | typedef vector vi; 20 | typedef pair pi; 21 | 22 | // typedef tree,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 23 | 24 | // bool sortbysec(const pair &a, const pair &b){ 25 | // return (a.second < b.second); 26 | // } 27 | 28 | 29 | vector factor[100001]; 30 | 31 | void printDivisors(int n) 32 | { 33 | for(int i = 1; i * i < n; i++) 34 | { 35 | if (n % i == 0){ 36 | factor[n].push_back(i); 37 | } 38 | 39 | } 40 | for(int i = sqrt(n); i > 1; i--) 41 | { 42 | if (n % i == 0){ 43 | factor[n].push_back(n/i); 44 | } 45 | } 46 | 47 | } 48 | 49 | int main(){ 50 | fio; 51 | int n = 100000; 52 | for(int i = 2; i <= n; i++){ 53 | printDivisors(i); 54 | } 55 | 56 | int t; 57 | cin >> t; 58 | while(t--){ 59 | int n; 60 | cin >> n; 61 | int ans = 0; 62 | for(int i = 2; i <= n; i++){ 63 | ans += (n/i)*factor[i].size(); 64 | if(n%i != 0){ 65 | int curr = n - (n/i)*i; 66 | 67 | int k = 0; 68 | for(auto x:factor[i]){ 69 | if(x > curr){ 70 | break; 71 | } 72 | k++; 73 | } 74 | ans += k; 75 | } 76 | } 77 | cout << ans; 78 | cout << endl; 79 | } 80 | 81 | return 0; 82 | } --------------------------------------------------------------------------------