diff --git a/.DS_Store b/.DS_Store index 8ae7172..8bc830c 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/CodeForces/Chat Screenshots.cpp b/CodeForces/Chat Screenshots.cpp new file mode 100644 index 0000000..3e656bf --- /dev/null +++ b/CodeForces/Chat Screenshots.cpp @@ -0,0 +1,51 @@ +#include +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; +} diff --git a/XSM OJ 重庆小码王集团OJ/.DS_Store b/XSM OJ 重庆小码王集团OJ/.DS_Store new file mode 100644 index 0000000..d5255b7 Binary files /dev/null and b/XSM OJ 重庆小码王集团OJ/.DS_Store differ diff --git a/XSM OJ 重庆小码王集团OJ/【字符串】石头剪子布.cpp b/XSM OJ 重庆小码王集团OJ/【字符串】石头剪子布.cpp new file mode 100644 index 0000000..2f1e489 --- /dev/null +++ b/XSM OJ 重庆小码王集团OJ/【字符串】石头剪子布.cpp @@ -0,0 +1,16 @@ +#include +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 ; + } +} \ No newline at end of file diff --git a/XSM OJ 重庆小码王集团OJ/希蒙的AC贴纸数.cpp b/XSM OJ 重庆小码王集团OJ/希蒙的AC贴纸数.cpp new file mode 100644 index 0000000..0e45ba5 --- /dev/null +++ b/XSM OJ 重庆小码王集团OJ/希蒙的AC贴纸数.cpp @@ -0,0 +1,21 @@ +#include +#include +#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; +} \ No newline at end of file diff --git a/XSM OJ 重庆小码王集团OJ/开关灯.cpp b/XSM OJ 重庆小码王集团OJ/开关灯.cpp new file mode 100644 index 0000000..00f3222 --- /dev/null +++ b/XSM OJ 重庆小码王集团OJ/开关灯.cpp @@ -0,0 +1,15 @@ +#include +using namespace std; +int main(){ + int n; + cin >> n ; + if(n % 2 == 1) + { + cout << 1 ; + } + else + { + cout << 0 ; + } + return 0; +} \ No newline at end of file diff --git a/XSM OJ 重庆小码王集团OJ/数字组合.cpp b/XSM OJ 重庆小码王集团OJ/数字组合.cpp index 5e2ac6d..8b605d7 100644 --- a/XSM OJ 重庆小码王集团OJ/数字组合.cpp +++ b/XSM OJ 重庆小码王集团OJ/数字组合.cpp @@ -1,12 +1,23 @@ -#include +#include + using namespace std; -int main(){ - int n; - cin >> n; - cout <> N; + + int count = 0; + for (int i = 0; i <= N; ++i) { + for (int j = 0; j <= N; ++j) { + 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; +} diff --git a/XSM OJ 重庆小码王集团OJ/求阴影面积.cpp b/XSM OJ 重庆小码王集团OJ/求阴影面积.cpp new file mode 100644 index 0000000..087f970 --- /dev/null +++ b/XSM OJ 重庆小码王集团OJ/求阴影面积.cpp @@ -0,0 +1,10 @@ +#include +using namespace std; + +int main() +{ + double a; + cin >> a ; + printf("%.2lf", a * a / 4); + return 0; +} \ No newline at end of file diff --git a/XSM OJ 重庆小码王集团OJ/算天数.cpp b/XSM OJ 重庆小码王集团OJ/算天数.cpp new file mode 100644 index 0000000..072e8d4 --- /dev/null +++ b/XSM OJ 重庆小码王集团OJ/算天数.cpp @@ -0,0 +1,67 @@ +#include +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; + } + } +} +// �����ӹ�Ԫ2021��1��1�����������ڵ����� +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; +} + diff --git a/洛谷刷题/.DS_Store b/洛谷刷题/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/洛谷刷题/.DS_Store differ diff --git a/洛谷刷题/P1005 [NOIP2007 提高组] 矩阵取数游戏.cpp b/洛谷刷题/P1005 [NOIP2007 提高组] 矩阵取数游戏.cpp new file mode 100644 index 0000000..9622aa0 --- /dev/null +++ b/洛谷刷题/P1005 [NOIP2007 提高组] 矩阵取数游戏.cpp @@ -0,0 +1,96 @@ +#include +#include +#include +#include +#include + +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; +}