Yuchang_Zhu's blog

By Yuchang_Zhu, history, 19 months ago, In English

I am usually able to solve two or more questions in competitions, always achieving a score of around 4000. Now that I am green, I haven't even solved a single question in this competition. Is this a degradation of my abilities, or is it just a poor state, or is it due to psychological reasons. Obviously, I lost points. I am both confused and distressed about this. And if I have any problems, how can I improve in my future practice and competition? I hope all the experts can provide more guidance, even if they only give me a little advice. Thank you.

Full text and comments »

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

By Yuchang_Zhu, history, 21 month(s) ago, In English

1681D - Required Length This is the topic of this question.

You are given two integer numbers, n and x. You may perform several operations with the integer x.

Each operation you perform is the following one: choose any digit y that occurs in the decimal representation of x at least once, and replace x by x⋅y.

You want to make the length of decimal representation of x (without leading zeroes) equal to n. What is the minimum number of operations required to do that?

Input The only line of the input contains two integers n and x (2≤n≤19; 1≤x<10n−1).

Output Print one integer — the minimum number of operations required to make the length of decimal representation of x (without leading zeroes) equal to n, or −1 if it is impossible.

This is the solution to this problem.(194061061)

include <bits/stdc++.h>

using namespace std; queue q; map <long long,int> m; int main() { int a; long long b; cin>>a>>b; q.push(b); m[b]=0; while (q.size()!=0) { b=q.front(); q.pop(); string s=to_string(b); if (s.size()==a) { cout<<m[b]; return 0; } for (int i=0;i<s.size();i++) { if (s[i]!='1'&&m[b*(s[i]-'0')]==0) { q.push(b*(s[i]-'0')); m[b*(s[i]-'0')]=m[b]+1; } } } cout<<"-1"<<endl; return 0; }

Full text and comments »

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

By Yuchang_Zhu, history, 21 month(s) ago, In English

Codeforces Round #852 (Div. 2) 1793A - Ещё одна акция

include <bits/stdc++.h>

using namespace std; int main() { int t; cin>>t; while (t--) { long long a,b,c,d; cin>>a>>b>>c>>d; if (a*d<=b*(d+1)) { long long ans=(c%(d+1))*min(a,b)+c/(d+1)*d*a; cout<<ans<<endl; } else { cout<<c*b<<endl; } } return 0; } 1793B - Федя и массив

include <bits/stdc++.h>

using namespace std; int main() { long long t; cin>>t; while (t--) { int a,b; cin>>a>>b; int cnt=0; cout<<(a-b)*2<<endl; for (int i=b;i<=a;i++) { cout<<i<<" "; } for (int i=a-1;i>=b+1;i--) { cout<<i<<" "; } cout<<endl; } return 0; } 1793C - Даша и поиски

include <bits/stdc++.h>

using namespace std; void solve() { int n; cin>>n; int a[222222]={},b[222222]={}; for (int i=0;i<n;i++) { cin>>a[i]; b[i]=a[i]; } sort(b,b+n); int l1=0,r1=n,l2=0,r2=n; bool f=1; while (f) { f=0; if (a[l1]==b[l2]) { l1++; l2++; f=1; } if (a[l1]==b[r2]) { l1++; r2--; f=1; } if (a[r1]==b[l2]) { r1--; l2++; f=1; } if (a[r1]==b[r2]) { r1--; r2--; f=1; } if (r1-l1<2) { cout<<"-1"<<endl; return ; } } cout<<l1+1<<" "<<r1+1<<endl; } int main() { int t; cin>>t; while (t--) { solve(); } return 0; } 1793D - Московские гориллы

include <bits/stdc++.h>

using namespace std; int p[222222],q[222222]; int main() { int n; cin>>n; for (int i=1;i<=n;i++) { int a; cin>>a; p[a]=i; } for (int i=1;i<=n;i++) { int a; cin>>a; q[a]=i; } int l=min(p[1],q[1]),r=max(p[1],q[1]); long long ans=1LL*l*(l-1)/2+1LL*(n-r+1)*(n-r)/2+1LL*(r-l)*(r-l-1)/2+1; for (int i=2;i<=n;i++) { int l2=1,r2=n; if (p[i]>=l&&p[i]<=r||q[i]>=l&&q[i]<=r) {

    }
    else
    {
       if (p[i]<l)
       {
         l2=max(l2,p[i]+1);
       }
       if (q[i]<l)
       {
         l2=max(l2,q[i]+1);
       }
       if (p[i]>r)
       {
         r2=min(r2,p[i]-1);
       }
       if (q[i]>r)
       {
         r2=min(r2,q[i]-1);
       }
       ans+=1LL*(l-l2+1)*(r2-r+1);
    }
    l=min(l,min(p[i],q[i]));
    r=max(r,max(p[i],q[i]));
}
cout<<ans<<endl;
return 0;

}

Full text and comments »

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

By Yuchang_Zhu, history, 21 month(s) ago, In English

I'm ten years old.I come from China.I like to write code with C++.I love codeforces!

Full text and comments »

  • Vote: I like it
  • +58
  • Vote: I do not like it

By Yuchang_Zhu, history, 21 month(s) ago, In English

I'm so mad that C is wrong because I got the wrong data type!

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it