farmaan_khan's blog

By farmaan_khan, history, 2 years ago, In English

https://codeforces.me/contest/1539/problem/A i am not able to solve the problem because of constraints the first solution is this

include <bits/stdc++.h>

define ll long long

using namespace std; void solve(){ ll n,x,t; cin>>n>>x>>t; int v[n]={0}; for(int i=1;i<n;i++) v[i]=v[i-1]+x; // for(auto i:v) cout<<i<<" "; // cout<<endl; int vv[n]={0}; for(int i=0;i<n;i++) vv[i]=v[i]+t; // for(auto i: vv ) cout<<i<<" "; // cout<<endl; ll sum=0; for(int i=0;i<n-1;i++){ ll upper1 = upper_bound(v, v+n, vv[i]) — v; sum+=upper1-i-1; } cout<<sum<<endl;

} int main() { int tc; cin>>tc; while(tc--){ solve(); } } 2.nd solution is this

include <bits/stdc++.h>

define ll long long

using namespace std; void solve(){ ll n,x,t; ll ans=(max(0ll,(n-t)/x)*(t/x))+min((n-1),t/(x-1))*(min(n,(t/x)))/2; cout<<ans<<endl;

} int main() { int tc; cin>>tc; while(tc--){ solve(); } } IN FIRST ONE IT SHOWS RUN TIME ERROR BECOZ OF CONSTRAINT AND IN 2ND IT SHOWS RANDOM NUMBER MAY BE BECAUSE OF 0LL HELP ME PLEASE!!!!1:(

  • Vote: I like it
  • -23
  • Vote: I do not like it

| Write comment?
»
2 years ago, # |
  Vote: I like it +8 Vote: I do not like it

For everyone's sanity :

Solution 1
Solution 2
  • »
    »
    2 years ago, # ^ |
      Vote: I like it -8 Vote: I do not like it

    brother can you please tell me that why these unrated dumb a(SS) downvote every single post either the post from new bie or from red coder

    • »
      »
      »
      2 years ago, # ^ |
        Vote: I like it +8 Vote: I do not like it

      if you have thought about why the guy above wrote his comment you would have know why people are downvoting you but you choose to write another stupid comment complaining about it, noice either you need to think before you talk or you're just a troll

      • »
        »
        »
        »
        2 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I can't tell if he's a troll either but he has almost 400 solved problems from the last 7 months O_O