mirror of
https://github.com/wczffl-503/OI-Codes.git
synced 2025-05-10 16:20:27 +08:00
d
This commit is contained in:
parent
4d5ff00243
commit
4b8c0c58eb
51
CodeForces/Chat Screenshots.cpp
Normal file
51
CodeForces/Chat Screenshots.cpp
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
const int N = 200005;
|
||||||
|
struct Edge{
|
||||||
|
int to, nxt;
|
||||||
|
}g[N];
|
||||||
|
int h[N], d[N], idx;
|
||||||
|
int a[N], q[N];
|
||||||
|
void add(int a,int b)
|
||||||
|
{
|
||||||
|
g[++idx].to = b, g[idx].nxt = h[a], h[a] = idx;
|
||||||
|
d[b] ++;
|
||||||
|
}
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int n, k;
|
||||||
|
scanf("%d%d", &n, &k);
|
||||||
|
for (int i = 1; i <= n; i ++ )
|
||||||
|
h[i] = d[i] = 0;
|
||||||
|
idx = 0;
|
||||||
|
for (int i = 1;i <= k; i ++ )
|
||||||
|
{
|
||||||
|
for (int j = 1; j <= n; j ++ )
|
||||||
|
scanf("%d", &a[j]);
|
||||||
|
for (int j = 2; j < n; j ++ )
|
||||||
|
add(a[j], a[j + 1]);
|
||||||
|
}
|
||||||
|
int hh = 0, tt = -1;
|
||||||
|
for (int i = 1; i <= n; i ++ )
|
||||||
|
if (d[i] == 0)
|
||||||
|
q[ ++ tt] = i;
|
||||||
|
while (hh <= tt)
|
||||||
|
{
|
||||||
|
int t = q[hh ++];
|
||||||
|
for (int i = h[t]; i; i = g[i].nxt)
|
||||||
|
{
|
||||||
|
int j = g[i].to;
|
||||||
|
if ( -- d[j] == 0)
|
||||||
|
q[ ++ tt] = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 1; i <= n; i ++ )
|
||||||
|
if (d[i] > 0)
|
||||||
|
{
|
||||||
|
cout << "NO";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
cout << "YES";
|
||||||
|
return 0;
|
||||||
|
}
|
BIN
XSM OJ 重庆小码王集团OJ/.DS_Store
vendored
Normal file
BIN
XSM OJ 重庆小码王集团OJ/.DS_Store
vendored
Normal file
Binary file not shown.
16
XSM OJ 重庆小码王集团OJ/【字符串】石头剪子布.cpp
Normal file
16
XSM OJ 重庆小码王集团OJ/【字符串】石头剪子布.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
signed main()
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
cin >> n ;
|
||||||
|
for(int i = 1; i <= n; ++ i)
|
||||||
|
{
|
||||||
|
string s1, s2;
|
||||||
|
cin >> s1 >> s2 ;
|
||||||
|
if(s1 == "Rock" && s2 == "Scissors" || s1 == "Scissors" && s2 == "Paper" || s1 == "Paper" && s2 == "Rock") cout << "Player1" << endl ;
|
||||||
|
else if(s1 == s2) cout << "Tie" << endl ;
|
||||||
|
else cout << "Player2" << endl ;
|
||||||
|
}
|
||||||
|
}
|
21
XSM OJ 重庆小码王集团OJ/希蒙的AC贴纸数.cpp
Normal file
21
XSM OJ 重庆小码王集团OJ/希蒙的AC贴纸数.cpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <cstdio>
|
||||||
|
#define int long long
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
signed main()
|
||||||
|
{
|
||||||
|
char a[1005];
|
||||||
|
scanf("%[^\n]", &a);
|
||||||
|
int i = 0, cnt = 0;
|
||||||
|
while(a[i] != '\0')
|
||||||
|
{
|
||||||
|
if(((a[i] == 'A' && a[i + 1] == 'C') || a[i] == a[i + 1]) && a[i] != ' ')
|
||||||
|
{
|
||||||
|
cnt ++ ;
|
||||||
|
}
|
||||||
|
i ++ ;
|
||||||
|
}
|
||||||
|
cout << cnt ;
|
||||||
|
return 0;
|
||||||
|
}
|
15
XSM OJ 重庆小码王集团OJ/开关灯.cpp
Normal file
15
XSM OJ 重庆小码王集团OJ/开关灯.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
int main(){
|
||||||
|
int n;
|
||||||
|
cin >> n ;
|
||||||
|
if(n % 2 == 1)
|
||||||
|
{
|
||||||
|
cout << 1 ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cout << 0 ;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
@ -1,12 +1,23 @@
|
|||||||
#include <bits/stdc++.h>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
int main(){
|
|
||||||
int n;
|
int main() {
|
||||||
cin >> n;
|
int N;
|
||||||
cout <<n<<n<<n<<" "<<n<<n<<n<<" "<<n<<n<<n<<" "<<n<<n<<n<<endl;
|
cin >> N;
|
||||||
cout <<" "<<n<<" "<<n<<" "<<n<<" "<<" "<<n<<" "<<n<<" "<<n<<endl;
|
|
||||||
cout <<n<<n<<n<<" "<<n<<" "<<n<<" "<<n<<n<<n<<" "<<n<<" "<<n<<endl;
|
int count = 0;
|
||||||
cout <<n<<" "<<" "<<n<<" "<<n<<" "<<n<<" "<<" "<<n<<" "<<n<<endl;
|
for (int i = 0; i <= N; ++i) {
|
||||||
cout <<n<<n<<n<<" "<<n<<n<<n<<" "<<n<<n<<n<<" "<<n<<n<<n<<endl;
|
for (int j = 0; j <= N; ++j) {
|
||||||
return 0;
|
for (int k = 0; k <= N; ++k) {
|
||||||
}
|
if (i != j && j != k && i != k && (i * 100 + j * 10 + k) % 2 != 0 && i != 0) {
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << count << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
10
XSM OJ 重庆小码王集团OJ/求阴影面积.cpp
Normal file
10
XSM OJ 重庆小码王集团OJ/求阴影面积.cpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
double a;
|
||||||
|
cin >> a ;
|
||||||
|
printf("%.2lf", a * a / 4);
|
||||||
|
return 0;
|
||||||
|
}
|
67
XSM OJ 重庆小码王集团OJ/算天数.cpp
Normal file
67
XSM OJ 重庆小码王集团OJ/算天数.cpp
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
bool isLeapYear(int year) {
|
||||||
|
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0 && year % 3200 != 0)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int getDaysOfMonth(int year, int month) {
|
||||||
|
if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12){
|
||||||
|
return 31;
|
||||||
|
}
|
||||||
|
if(month == 4 || month == 6 || month == 9 || month == 11){
|
||||||
|
return 30;
|
||||||
|
}
|
||||||
|
if(month == 2){
|
||||||
|
if(isLeapYear(year)==1){
|
||||||
|
return 29;
|
||||||
|
}else{
|
||||||
|
return 28;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ӹ<EFBFBD>Ԫ2021<32><31>1<EFBFBD><31>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
int calcDays(int year, int month, int day) {
|
||||||
|
int days = 0;
|
||||||
|
for (int i = 2021; i < year; i++) {
|
||||||
|
if(isLeapYear(i)==1){
|
||||||
|
days +=366;
|
||||||
|
}else{
|
||||||
|
days +=365;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 1; i < month; i++) {
|
||||||
|
days += getDaysOfMonth(year, i);
|
||||||
|
}
|
||||||
|
days += day-1;
|
||||||
|
return days;
|
||||||
|
}
|
||||||
|
|
||||||
|
int calcWeekday(int days) {
|
||||||
|
days+=5;
|
||||||
|
days%=7;
|
||||||
|
if(days==0){
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
return days;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int year, month, day;
|
||||||
|
cin >> year >> month >> day;
|
||||||
|
|
||||||
|
int days = calcDays(year, month, day);
|
||||||
|
int weekday = calcWeekday(days);
|
||||||
|
|
||||||
|
cout << days << endl;
|
||||||
|
cout << '*' << weekday << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
BIN
洛谷刷题/.DS_Store
vendored
Normal file
BIN
洛谷刷题/.DS_Store
vendored
Normal file
Binary file not shown.
96
洛谷刷题/P1005 [NOIP2007 提高组] 矩阵取数游戏.cpp
Normal file
96
洛谷刷题/P1005 [NOIP2007 提高组] 矩阵取数游戏.cpp
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cstring>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
const int MAXN = 85, Mod = 10000;
|
||||||
|
int n, m;
|
||||||
|
int ar[MAXN];
|
||||||
|
|
||||||
|
struct HP {
|
||||||
|
int p[505], len;
|
||||||
|
HP() {
|
||||||
|
memset(p, 0, sizeof p);
|
||||||
|
len = 0;
|
||||||
|
}
|
||||||
|
void print() {
|
||||||
|
printf("%d", p[len]);
|
||||||
|
for (int i = len - 1; i > 0; i--) {
|
||||||
|
if (p[i] == 0) {
|
||||||
|
printf("0000");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (int k = 10; k * p[i] < Mod; k *= 10)
|
||||||
|
printf("0");
|
||||||
|
printf("%d", p[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} f[MAXN][MAXN], base[MAXN], ans;
|
||||||
|
|
||||||
|
HP operator + (const HP &a, const HP &b) {
|
||||||
|
HP c; c.len = max(a.len, b.len); int x = 0;
|
||||||
|
for (int i = 1; i <= c.len; i++) {
|
||||||
|
c.p[i] = a.p[i] + b.p[i] + x;
|
||||||
|
x = c.p[i] / Mod;
|
||||||
|
c.p[i] %= Mod;
|
||||||
|
}
|
||||||
|
if (x > 0)
|
||||||
|
c.p[++c.len] = x;
|
||||||
|
return c;
|
||||||
|
} //高精+高精
|
||||||
|
|
||||||
|
HP operator * (const HP &a, const int &b) {
|
||||||
|
HP c; c.len = a.len; int x = 0;
|
||||||
|
for (int i = 1; i <= c.len; i++) {
|
||||||
|
c.p[i] = a.p[i] * b + x;
|
||||||
|
x = c.p[i] / Mod;
|
||||||
|
c.p[i] %= Mod;
|
||||||
|
}
|
||||||
|
while (x > 0)
|
||||||
|
c.p[++c.len] = x % Mod, x /= Mod;
|
||||||
|
return c;
|
||||||
|
} //高精*单精
|
||||||
|
|
||||||
|
HP max(const HP &a, const HP &b) {
|
||||||
|
if (a.len > b.len)
|
||||||
|
return a;
|
||||||
|
else if (a.len < b.len)
|
||||||
|
return b;
|
||||||
|
for (int i = a.len; i > 0; i--)
|
||||||
|
if (a.p[i] > b.p[i])
|
||||||
|
return a;
|
||||||
|
else if (a.p[i] < b.p[i])
|
||||||
|
return b;
|
||||||
|
return a;
|
||||||
|
} //比较取最大值
|
||||||
|
|
||||||
|
void BaseTwo() {
|
||||||
|
base[0].p[1] = 1, base[0].len = 1;
|
||||||
|
for (int i = 1; i <= m + 2; i++){ //这里是m! m! m! 我TM写成n调了n年...
|
||||||
|
base[i] = base[i - 1] * 2;
|
||||||
|
}
|
||||||
|
} //预处理出2的幂
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
scanf("%d%d", &n, &m);
|
||||||
|
BaseTwo();
|
||||||
|
while (n--) {
|
||||||
|
memset(f, 0, sizeof f);
|
||||||
|
for (int i = 1; i <= m; i++)
|
||||||
|
scanf("%d", &ar[i]);
|
||||||
|
for (int i = 1; i <= m; i++)
|
||||||
|
for (int j = m; j >= i; j--) { //因为终值是小区间,DP自然就从大区间开始
|
||||||
|
f[i][j] = max(f[i][j], f[i - 1][j] + base[m - j + i - 1] * ar[i - 1]);
|
||||||
|
f[i][j] = max(f[i][j], f[i][j + 1] + base[m - j + i - 1] * ar[j + 1]);
|
||||||
|
} //用结构体重载运算符写起来比较自然
|
||||||
|
HP Max;
|
||||||
|
for (int i = 1; i <= m; i++)
|
||||||
|
Max = max(Max, f[i][i] + base[m] * ar[i]);
|
||||||
|
ans = ans + Max; //记录到总答案中
|
||||||
|
}
|
||||||
|
ans.print(); //输出
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user