E. Good Triples
1.B. Rudolf and 1212.C. Rudolf and the Ugly String3.A. Rudolf and the Ticket4.D. Rudolf and the Ball Game5.G. Rudolf and Subway6.C. Choose the Different Ones!7.B. Following the String8.E. Klever Permutation9.D. Find the Different Ones!10.B. YetnotherrokenKeoard11.C. Removal of Unattractive Pairs12.D. Jumping Through Segments
13.E. Good Triples
14.F. Shift and Reverse15.C. Nikita and LCM16.B. Prefiquence17.E. Vlad and a Pair of Numbers18.D. XOR Construction19.C. Non-coprime Split20.D. Divide and Equalize21.E. Block Sequence22.D. In Love23.C. Theofanis' Nightmare24.D. Yet Another Monster Fight25.C. Count Triangles26.E. Count Paths27.Collecting Numbers II28.C. Even Subarrays29.C. Perform Operations to Maximize Score30.F. Color Rows and Columns31.C. To Become Max首先假定已经找到abc符合题目条件。则我们假定a1,a2,a3...;b1,b2,b3...;c1,c2,c3...为abc各个位置上的数字,那么
a1 a2 a3
b1 b2 b3
+ c1 c2 c3
----------------
x1 x2 x3
又由digsum等式可知a1+b1+c1+...=x1+x2+x3。
那么我们根据竖式不难发现在每一位进行加法时不能够产生进位,否则将不满足digsum等式。
即a3+b3+c3=x3;a2+b2+c2=x2;a1+b1+c1=x1。
所以我们只需要求出x每一位有几种拆法,然后再相乘。
拆分方法我们可以借鉴高中隔板法:有Xi个小球要求分成三部分,有几种分法。
主要代码:
#include<bits/stdc++.h> using namespace std; int main(){ int a[15]={1,3,6,10,15,21,28,36,45,55}; //Xi个小球的分法 int t; cin>>t; while (t--){ int n; cin>>n; if (n==0){ //0需要特判 printf("%d\n",1); continue; } long long int sum=1; //longlongint避免溢出 while (n!=0){ //每一位方法数相乘 sum*=a[n%10]; n/=10; } cout<<sum<<endl; } return 0; }
合集:
codeforces
分类:
刷题
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】