Submission #646065

# Submission time Handle Problem Language Result Execution time Memory
646065 2022-09-28T14:41:13 Z mr_robot_545 Savrsen (COCI17_savrsen) C++17
0 / 120
2 ms 340 KB
//بسم الله الرحمن الرحيم
// i love mancity
#include<bits/stdc++.h>
#include <stack>
#include <vector>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define             endl "\n"
#define             ll long long
#define             f(a) for(int i=0;i<a;i++)
#define             rf(a) for(int i=a-1;i>=0;i--)
#define             w  int t;cin>>t;while(t--)
#define             all(v) v.begin(),v.end()
#define             yes cout<<"YES"<<endl;
#define             no cout<<"NO"<<endl;
#define             prev2pn(x) pow(2,floor(log2(x)))
#define             MR_Robot iostream::sync_with_stdio(false);cin.tie(nullptr); \
                    cout.tie(nullptr);
#define             arrRange(a , l , r) int _##a[(r-l)+1]; int* a= _##a-l;
#define             ordered_set tree<int, null_type,less<int>, \
                    rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
const ll MOD=1e9+7;
const int N= 1e3+5;
const double EPS = 1e-7;
const double PI = 3.14159265;
//void fact(ll  c){
//    int g=500000;
//    vector<ll>fa(g, 0);
//    fa[0]=1;
//    for (int i = 2; i <=c ; ++i) {
//        for (int j = 0; j <g ; ++j) {
//            fa[j]*=i;
//
//        }
//        for (int j = 0; j <g ; ++j) {
//            if(fa[j] > 9){
//                fa[j + 1]+=(fa[j] / 10);
//                fa[j]%=10;
//            }
//        }
//    }
//    int index=0;
//    for (int i = g-1; i >=0 ; --i) {
//        if(fa[i] == 0)index=i;
//        else break;
//    }
//    for (int i = index-1; i >=0 ; --i) {
//        cout << fa[i];
//    }
//}
//int power(ll xx, ll nn)
//{
//    ll result = 1;
//    while (nn > 0) {
//        if ((nn & 1) == 1) // y is odd
//        {
//            result = (result%MOD) * (xx%MOD);
//        }
//        xx = (xx%MOD) * (xx%MOD);
//        nn = nn >> 1; // y=y/2;
//    }
//    return (result%MOD);
//}
int n,m,x,y;
void sieve(int c){ //nlog(log(n))
    vector<int>primes(c);
    int cnt=0;
    for (int i = 1; i <c ; ++i) {
        for (int j = i+i; j <c ; j+=i) {
                primes[j]+=i;
        }
    }
    ll sum=0;
    for (int i = n; i <=m ; ++i) {
        sum+=abs(primes[i]-i);
    }
    cout<<sum<<endl;
}
//ll factorization(ll nn) { //at most log(n)
//    int cnt=0;
//    ll temp=nn;
//    vector<ll>factors;
//    while (nn % 2 == 0) {
//        cnt++;
//        factors.push_back(2);
//        nn /= 2;
//    }
//    for (int i = 3; i * i <= nn; i+=2) {
//        while (nn % i == 0) {
//            cnt++;
//            factors.push_back(i);
//            nn /= i;
//        }
//    }
//    if (nn > 1) {
//        factors.push_back(nn);
//    }
//    map<ll, ll> mp;
//    for (int i = 0; i < int(factors.size()); ++i) {
//        mp[factors[i]]++;
//    }
//    ll a = 1;
//    for (auto u: mp) {
//        a *=((power(u.first,u.second+1)-1)/(u.first-1));
//    }
//    a-=temp;
//    ll sum=abs(temp-a);
//    return sum;
//
//}


const int dx[] = {1, -1, 0, 0,1,-1} , dy[] = {0, 0, 1, -1,1,-1};
const string dir[]={"D","U","R","L","UR","DR","UL","DL"};
const string dir1[]={"Carrots","Kiwis","Grapes"};
arrRange(aa,-N ,N);
vector<int>adj[N];
bool vis[N];
int child[N];


void solve(){
    cin>>n>>m;
    ll sum=0;
    sieve(m+1);

}
int main() {
    MR_Robot
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
//    w{
    solve();
//    }

    return 0;
}

Compilation message

savrsen.cpp: In function 'void sieve(int)':
savrsen.cpp:69:9: warning: unused variable 'cnt' [-Wunused-variable]
   69 |     int cnt=0;
      |         ^~~
savrsen.cpp: In function 'void solve()':
savrsen.cpp:126:8: warning: unused variable 'sum' [-Wunused-variable]
  126 |     ll sum=0;
      |        ^~~
savrsen.cpp: In function 'int main()':
savrsen.cpp:133:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  133 |     freopen("in.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
savrsen.cpp:134:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  134 |     freopen("out.txt", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Incorrect 2 ms 340 KB Output isn't correct
3 Incorrect 2 ms 340 KB Output isn't correct
4 Incorrect 2 ms 340 KB Output isn't correct
5 Incorrect 2 ms 340 KB Output isn't correct
6 Incorrect 2 ms 340 KB Output isn't correct
7 Incorrect 2 ms 340 KB Output isn't correct
8 Incorrect 2 ms 340 KB Output isn't correct