Educational cf round 80 (Div. 2) A,B,C
程序员文章站
2022-06-04 18:18:49
...
Contest:Click Here
A. Deadline
签到题,很玄妙的用
推了一下,一发就过了。AC代码
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int t;
double n,d;
cin >> t;
while(t--)
{
cin >> n >> d;
if(d <= n)
cout << "YES" << endl;
else
{
double s = 2*sqrt(d)-1;
if(n >= s)
{
cout << "YES" << endl;
}
else
cout << "NO" << endl;
}
}
return 0;
}
B. Yet Another Meme Problem
签到题,简单的推算之后发现结果只和 b 有关,所有的答案和 a 都能*组合,所以最后算出来的答案乘以 a 即最后输出的答案。
根据推导出来的只和 b 有关的公式可以看出,满足条件的 conc(a,b) 只能等于9,99,999,9999…所以可以判断简化为比较 b 和 pow(10,b.length())-1 比较,分两种情况处理。
AC代码
#include <iostream>
#include <cmath>
#define ll long long
using namespace std;
ll len(ll k)
{
int cn = 0;
while(k)
{
k/=10;
cn++;
}
return cn;
}
int main()
{
int t;
ll a,b;
cin >> t;
while(t--)
{
int flag = 0;
ll ans = 0;
cin >> a;
cin >> b;
int l = len(b);
//cout << jiu(l);
if(b < pow(10,l)-1)
ans = a*(l-1);
if(b == pow(10,l)-1)
ans = a*l;
cout << ans << endl;
}
return 0;
}
C. Two Arrays
简单dp,具体思路在注释 有参考
//a不递减 b不递增
//a 和 b逆序放一起 找2*m长度 能用n个数构造的非递减(不一定递增)序列的可能个数
#include <iostream>
#define ll long long
using namespace std;
const int maxn = 1e3+5;
const int p = 1e9+7;
ll dp[maxn][maxn];//dp[i][j] 第i个位置(i为1到2*m)放j数字(j为1到n)的可能方案数
int main()
{
int n,m;
scanf("%d%d",&n,&m);
for(int i = 1;i <= n;i++)
dp[1][i] = 1;
for(int i = 2;i <= 2*m;i++)
for(int j = 1;j <=n;j++)
{
for(int k = 1;k <= j;k++)
{
dp[i][j] = (dp[i][j] + dp[i-1][k])%p;//前i-1位放k(代表小于j的所有数)方案数之和
}
}
ll ans = 0;
for(int i = 1;i <= n;i++)
{
ans += dp[2*m][i];
ans %= p;
}
printf("%lld\n",ans);
return 0;
}
```
推荐阅读
-
Educational Codeforces Round 85 (Rated for Div. 2) C. Circle of Monsters(前缀和 预处理 贪心)
-
Educational Codeforces Round 93 (Rated for Div. 2) B - Substring Removal Game
-
Educational Codeforces Round 99 (Rated for Div. 2) C. Ping-pong
-
Codeforces Round #483 (Div. 2) (A+B+C+D)
-
Codeforces Round #249 (Div. 2) A B C_html/css_WEB-ITnose
-
C. Mortal Kombat Tower(动态规划)Educational Codeforces Round 95 (Rated for Div. 2)
-
Educational Codeforces Round 88 (Rated for Div. 2)C. Mixing Water[题解](数学)
-
Educational Codeforces Round 95 (Rated for Div. 2)C. Mortal Kombat Tower【dp】
-
CF-Educational Codeforces Round 44 (Rated for Div. 2)-E-Pencils and Boxes
-
Educational Codeforces Round 86 (Rated for Div. 2)---C