喵喵教会的祭品

AC_code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define size(v) ((int)v.size())
#define all(v) v.begin(), v.end()
#define x first
#define y second
using namespace std;
int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};

void solve()
{
puts("4396 = 28 x 157");
puts("5346 = 18 x 297");
puts("5346 = 27 x 198");
puts("5796 = 12 x 483");
puts("5796 = 42 x 138");
puts("6952 = 4 x 1738");
puts("7254 = 39 x 186");
puts("7632 = 48 x 159");
puts("7852 = 4 x 1963");
}

int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _; // cin >> _;
_ = 1;
while (_--)
solve();

return 0;
}

Apples Prologue / 苹果和虫子

AC_code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define size(v) ((int)v.size())
#define all(v) v.begin(), v.end()
#define x first
#define y second
using namespace std;
int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};

void solve()
{
int m,t,s;
cin >> m >> t >> s;
if(t){
int c = ceil(s * 1.0 / t);
if(m < c) cout << 0 << endl;
else cout << m - c << endl;
}else cout << 0 << endl;
}

int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _; // cin >> _;
_ = 1;
while (_--)
solve();

return 0;
}

杨辉三角

AC_code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define size(v) ((int)v.size())
#define all(v) v.begin(), v.end()
#define x first
#define y second
using namespace std;
int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};

const int N = 25;

int f[N][N];

void solve()
{
int n;
cin >> n;
f[0][0] = 1;
for(int i = 1;i <= n;i ++){
for(int j = 1;j <= i;j ++){
f[i][j] = f[i - 1][j - 1] + f[i - 1][j];
cout << f[i][j] << " \n"[i == j];
}
}
}

int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _; // cin >> _;
_ = 1;
while (_--)
solve();

return 0;
}

计算阶乘

AC_code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define size(v) ((int)v.size())
#define all(v) v.begin(), v.end()
#define x first
#define y second
using namespace std;
int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};

const int N = 25;

int f[N][N];

void solve()
{
int n;
cin >> n;
f[0][0] = 1;
for(int i = 1;i <= n;i ++){
for(int j = 1;j <= i;j ++){
f[i][j] = f[i - 1][j - 1] + f[i - 1][j];
cout << f[i][j] << " \n"[i == j];
}
}
}

int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _; // cin >> _;
_ = 1;
while (_--)
solve();

return 0;
}

青蛙爬井

AC_code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define size(v) ((int)v.size())
#define all(v) v.begin(),v.end()
#define x first
#define y second
using namespace std;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};


void solve()
{
int h,u,d,cnt = 0,now = 0;
cin >> h >> u >> d;
while(now < h){
cnt ++;
now += u;
if(now >= h) break;
now -= d;
}
cout << cnt << endl;
}


int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int _; // cin >> _;
_ = 1;
while(_ --) solve();

return 0;
}

月份天数

AC_code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define size(v) ((int)v.size())
#define all(v) v.begin(), v.end()
#define x first
#define y second
using namespace std;
int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};

int months[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

void solve()
{
int y,t;
cin >> y >> t;
if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) months[2] = 29;
else months[2] = 28;

cout << months[t] << endl;
}

int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _; // cin >> _;
_ = 1;
while (_--)
solve();

return 0;
}