1002 Kanade Doesn’t Want to Learn CG
链接:https://vjudge.net/problem/HDU-7127
大概思路就是
1.判断二次函数顶部是否超过篮板
2.将篮板作为x轴,判断是否有解
3.如果:(x1,x2为方程的两个解)
①.未反弹直接从上往下进洞,表现为:x1小于球筐左端,x2在篮筐区间
②.反弹后进洞,表现为x1小于球筐左端,x2在篮筐对称区间,且x=篮网右端的时候,函数值小于篮板高度
球进啦!!
下附代码,人菜求轻喷QAQ
#include <iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<string>
#include<cstdio>
#include<queue>
#include<cstdlib>
#define LL long long
using namespace std;
double n, a, b, c, x0, yy, x1, yy1, y2;
double f, x;
int main() {
ios::sync_with_stdio(false);
cin >> n;
while (n--) {
cin >> a >> b >> c;
cin >> x0 >> x1 >> yy >> yy1 >> y2;
double x2 = x1 - x0 + x1;
double top = (4 * a * c - b * b) / (4 * a);
if (top < yy)
{
cout << "No\n";
}
else
{
double ans1, ans2, xtop;
c -= yy;
if (b * b - 4 * a * c < 0)
{
cout << "No\n";
}
else
{
ans1 = ((-b) + sqrt(b * b - 4 * a * c)) / (2 * a);
ans2 = ((-b) - sqrt(b * b - 4 * a * c)) / (2 * a);
c += yy;
xtop = a * x1 * x1 + b * x1 + c;
if (ans1 < x0 && ans2 > x0 && ans2 < x1) cout << "Yes\n";
else if (ans1 < x0 && ans2 > x1 && ans2 < x2 && xtop <= y2)cout << "Yes\n";
else cout << "No\n";
}
}
}
}
1004 Primality Test
题目链接:https://vjudge.net/problem/HDU-7129
签到题
f(x)为找到大于x的第一个质数,所以f(f(x))则为大于x的第二个质数。
/因为一般情况质数都为奇数,两个不同奇数的平均数是偶数,所以不成立,除了2和3/
↑粗浅且无严格证明的解释↑
因此加个特判,x=1的时候YES,其他情况都是NO
下附代码,人菜求轻喷QAQ
#include <iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<string>
#include<cstdio>
#include<queue>
#include<cstdlib>
#define LL long long
using namespace std;
int main()
{
int _;
scanf("%d", &_);
while (_--)
{
LL n;
scanf("%lld", &n);
if (n == 1) printf("YES\n");
else printf("NO\n");
}
return 0;
}
1005 Monopoly//占坑之后写,好麻烦
题目链接:https://vjudge.net/problem/HDU-7130
比赛的时候越写心态越崩,最后还是没调出来,赛后才补
1006 Nun Heh Heh Aaaaaaaaaaa
题目链接:https://vjudge.net/problem/HDU-7131
大概思路:
DP,记录nunhehheh的方案数,然后记录每个位置a的后缀和,然后算,楞算!
大概要注意下面几点:
1.qmi中返回值要减一,因为2的n次方包含了长度为0的串
2.记得MOD
3.在hdu用string要加单独的#include<string>
4.记得清空数组(btw,每日一问hdu什么时候能用memset)
下附代码,不过肯定是有更简洁的版本,我写的太繁琐了
#include <iostream>
#include <string>
#define LL long long
#define MOD 998244353
using namespace std;
string s;
LL nun[100010][10];
LL a[100010];
int n;
LL ans;
LL qmi(LL qwq) {
LL res = 1;
LL x = 2;
while (qwq != 0) {
if (qwq & 1) res = (res * x) % MOD;
x = (x * x) % MOD;
qwq /= 2;
}
return res - 1 + MOD;
}
int main() {
ios::sync_with_stdio(false);
cin >> n;
while (n--)
{
cin >> s;
ans = 0;
int len = s.length();
for (int i = 0; i < 100010; i++)
{
a[i] = 0;
for (int j = 0; j < 10; j++)
{
nun[i][j] = 0;
}
}
if (s[0] == 'n') nun[0][1]++;
for (int i = len - 1; i >= 0; i--)
{
if (s[i] == 'a') a[i] = (a[i + 1] + 1);
else a[i] = a[i + 1];
}
for (int i = 1; i < len; i++)
{
if (s[i] == 'n')
{
nun[i][1] = nun[i - 1][1] + 1;
nun[i][2] = nun[i - 1][2];
nun[i][3] = nun[i - 1][2] + nun[i - 1][3];
nun[i][4] = nun[i - 1][4];
nun[i][5] = nun[i - 1][5];
nun[i][6] = nun[i - 1][6];
nun[i][7] = nun[i - 1][7];
nun[i][8] = nun[i - 1][8];
nun[i][9] = nun[i - 1][9];
}
else if (s[i] == 'u')
{
nun[i][1] = nun[i - 1][1];
nun[i][2] = nun[i - 1][1] + nun[i - 1][2];
nun[i][3] = nun[i - 1][3];
nun[i][4] = nun[i - 1][4];
nun[i][5] = nun[i - 1][5];
nun[i][6] = nun[i - 1][6];
nun[i][7] = nun[i - 1][7];
nun[i][8] = nun[i - 1][8];
nun[i][9] = nun[i - 1][9];
}
else if (s[i] == 'h')
{
nun[i][1] = nun[i - 1][1];
nun[i][2] = nun[i - 1][2];
nun[i][3] = nun[i - 1][3];
nun[i][4] = nun[i - 1][3] + nun[i - 1][4];
nun[i][5] = nun[i - 1][5];
nun[i][6] = nun[i - 1][5] + nun[i - 1][6];
nun[i][7] = nun[i - 1][6] + nun[i - 1][7];
nun[i][8] = nun[i - 1][8];
nun[i][9] = nun[i - 1][8];
ans += nun[i][9] * qmi(a[i]) % MOD;
}
else if (s[i] == 'e')
{
nun[i][1] = nun[i - 1][1];
nun[i][2] = nun[i - 1][2];
nun[i][3] = nun[i - 1][3];
nun[i][4] = nun[i - 1][4];
nun[i][5] = nun[i - 1][5] + nun[i - 1][4];
nun[i][6] = nun[i - 1][6];
nun[i][7] = nun[i - 1][7];
nun[i][8] = nun[i - 1][7] + nun[i - 1][8];
nun[i][9] = nun[i - 1][9];
}
else
{
nun[i][1] = nun[i - 1][1];
nun[i][2] = nun[i - 1][2];
nun[i][3] = nun[i - 1][3];
nun[i][4] = nun[i - 1][4];
nun[i][5] = nun[i - 1][5];
nun[i][6] = nun[i - 1][6];
nun[i][7] = nun[i - 1][7];
nun[i][8] = nun[i - 1][8];
nun[i][9] = nun[i - 1][9];
}
for (int j = 1; j <= 9; j++) nun[i][j] %= MOD;
}
cout << ans % MOD << "\n";
}
}