ICode9

精准搜索请尝试: 精确搜索
  • cf1100 没看懂题意2022-09-12 01:30:09

    https://codeforces.com/contest/1726/problem/B 英文 the bitwise XOR of all elements in a (which are strictly less than ai) is 0. 在a中比ai小的所有元素小于0 首先n>m一定无法构造。然后异或和为0,代表着小于ai的aj一定有偶数个,因为aj^aj=0。为了方便,我们首先用1填充,如果n%

  • scanf读字符的坑2022-09-11 22:01:32

    int main() { char a = 0; char b = 0; scanf("%c", &a); scanf("%c", &b); printf("a=%c,b=%c", a, b); return 0; } 输出结果: 输出b的ascii码值: printf("a=%c,b=%d", a, b); 输出结果: a=q,b=10------b=10ascii码值是换行符'\

  • 编写休闲小游戏2022-09-11 12:32:17

    #include<stdio.h> #include<stdlib.h> #include<time.h> #include<windows.h> #include<string.h> #define ROW 3 #define COL 3 int Login() { char User[20]; char Password[20]; char ch; int ret; int n;

  • 来点基础的练习题吧,看见CSDN这类基础的代码不多2022-09-10 09:30:43

    来点基础的练习题吧,看见CSDN这类基础的代码不多 //正三角形 void ex03(){ int i,k=0, rows, space; printf("请输入三角形的层次:"); scanf("%d",&rows); for(i=1; i<=rows; i++,k=0){ //k值每次循环都要重新初始化 for(space=1; space<=rows-i; space++){ printf(" ");

  • Problem P11. [算法课动态规划]爬楼梯2022-09-08 13:34:24

    动态规划当前状态和前一状态相关。到m阶楼梯的方法等于到m-1和m-2的方法相加 #include<iostream> #include<bits/stdc++.h> #include<cstdio> using namespace std; int n; int cnt[25]; int main() { scanf("%d", &n); cnt[0] = 1; cnt[1] = 1; for (int

  • 记刷题过程中发现的C++与C的差异2022-09-06 16:30:08

    前言 上大学了,学 c。 标题嫖自@快乐永恒 正题 01 #include <stdio.h> int main() { long long a, b; scanf("%lld %lld", &a, &b); printf("%lld %lld %lld %lld %lld", a + b, a - b, a * b, a / b, a % b); return 0; } #include <cstdio>

  • 5:判断语句2022-09-06 13:00:17

    判断语句 C 语言把任何非零和非空的值假定为 true,把零或 null 假定为 false。 if判断 #include<stdio.h> int main(void) { /* if (条件) { // 就去执行的东西 } */ int age; printf("please input your age : \n"); scan

  • 在vs2022中scanf和scnaf_s的区别2022-09-06 00:32:27

     在C Primer Plus中有这样一代码在vs2022编写中出现的错误: /praise1.c--使用不同类型的字符串*/ #include <stdio.h> $define PRAISE"You are an extrordinary being"   int main() {   char name[40];   printf("What`s your name?");   scanf_s("%s",name);   pri

  • c语音键盘输入和屏幕输出2022-09-05 23:35:04

    键盘输入和屏幕输出 单个字符的输入输出 getchar字符输入 putchar字符输出 缓冲区优先 每次只读一个字符 输出输入量不加引号,只有转义字符加 实践:大小写转换 注意:getchar()没有参数,函数的返回值就是从终端键盘读入的字符 使用方法 ch=getchar(); 而不是 getchar(ch); 小写比大写的

  • codeforces#818(Div.2)2022-09-04 03:01:52

    算了,不摆烂了,事情太多,没摆烂的时间了。在我研究出如何把某平台上多年积累的流量变现前,就继续用这个博客记录日常吧。之后所有内容基于时间,就懒得设置标签分类之类的了。 昨晚参加完卓工面试后,时隔两年,再次打了\(Div.2\),嗯,然后敲完\(A\)就睡着了没办法,刚军训完太累了辣……能在\(Di

  • Problem P04. [算法课分治] 找到 k 个最小数2022-09-03 03:02:04

    先sort排序,在输出最小的k个数。 #include<iostream> #include<bits/stdc++.h> #include<cstdio> using namespace std; int n, k; int arr[10005]; int main() { scanf("%d %d", &n, &k); for (int i = 0; i < n; i++){ scan

  • Problem P05. [算法课分治] 寻找第 k 个最大元素2022-09-03 03:01:32

    先sort进行排序,然后输出第k大的元素即可 #include<iostream> #include<bits/stdc++.h> #include<cstdio> using namespace std; int n, k; int arr[10005]; int main() { scanf("%d %d", &n, &k); for (int i = 0; i < n; i++){

  • CSP_202206-2_寻宝!大冒险!2022-09-02 21:34:26

    CSP_202206-2_寻宝!大冒险 题目链接 思路 相当于判断两个有限集合AB之间是不是满射和单射,只需要保证以下两点 A和B元素个数相等 A中每个元素都能通过映射\(\psi\)到B中一个元素,且\(\psi(a_1)=\psi(a_2) \iff a_1 = a_2\) 坑 输入的矩阵格式和我们平常看到的坐标系,xy轴是反过来的

  • CF808G Anthem of Berland2022-08-30 14:01:14

    给定 \(s\) 和 \(t\) ,其中 \(s\) 中有 \(k\) 个 ? ,求 \(s\) 补齐 ? 后匹配 \(t\) 的最大次数。 \(|s|\times |t|\leq 10^7\)。 先用一组数据 \(HACK\) 掉贪心做法: (贪心只能过样例) a?ba aba 正确输出 \(1\) 考虑正确做法,题目中给出 \(|t|\times|s|\leq10^7\) ,暗示 \(O(|t||s|)\)

  • ABC #266 B、C、D、E、F2022-08-28 21:01:01

    B - Modulo Number (atcoder.jp) 移项之后发现就是带余除法的形式,直接取模就可以了。(某sb写了个exgcd) const int p=998244353,k=1; typedef long long ll; ll n; ll exgcd(int a,int b,ll &x,ll &y){ if(!b){ x=1; y=0; return a; } ll d=exgcd(b,a%b,y,x); y-=a/b*x; r

  • CF1121B Mike and Children 题解2022-08-25 12:04:50

    题意翻译十分简洁,我说几点需要注意的。 最多能选几个数? 这是错的,要给出最多选出几对数。 现在我们就珂以开始了。 我的做法理论时间复杂度是 O(n^3)O(n3) 的暴力,但是因为常数较小于是珂以通过。 首先我们观察发现 a_iai​ 的范围很小,只有 10^5105 于是我们把给出的数标记

  • 2022杭电多校第十场7、3、9、42022-08-21 15:30:52

    1007 Even Tree Split 先考虑最简单的情况,如下图的边\((3,4)\),我们把这条边切掉,最后会留下一部分的点数为2,另一部分的点数依然是偶数。 进一步思考可以知道,对于边\((u,v)\),只要v子树的点数是偶数,这条边就可以切除。 再进一步,统计所有可以切除的边的数量,可以知道,只要从中选择任意多

  • 线段树2022-08-20 18:05:03

    https://www.luogu.com.cn/problem/P3372 1 #include <iostream> 2 #include <cstdio> 3 using namespace std; 4 #define lson l,mid,rt<<1 5 #define rson mid+1,r,rt<<1|1 6 #define ll long long 7 const int mac=1e5+50; 8 ll tree[m

  • codeforces963D. Frequency of String【哈希】2022-08-20 11:02:40

    我的腿让我停下,可是我的心却不许我这么做 今天又是为了明知多半不可能的事情奔波一早,一天里,出了很多丑,犯了很多错,见了很多人,有了很多意想不到的收获,我选择了我的生存方式,我努力地撒野生长。现在是凌晨一点了,我不敢去睡觉,因为夜幕总会揭开我的绝望,总是这样。武汉大学的校训是什么

  • 练习3-2 计算符号函数的值2022-08-16 14:30:35

    #include<stdio.h> int main() { int n; scanf("%d", &n); if(n>0){ printf("sign(%d) = 1",n); }else if(n<0){ printf("sign(%d) = -1",n); }else{ printf("sign(%d)

  • CF1712B Woeful Permutation 题解2022-08-15 17:30:08

    题目传送门 题目简介 给定一个正整数 \(n\),构造一个数列 \(p\),使 \(1\) 到 \(n\) 中每一个数都出现且只出现 \(1\) 次。 求最大的 \(\sum\limits_{i=1}^n\operatorname{lcm}(i, p_i)\),并输出取得最大值时的数列。 思路 基础知识:\(\operatorname{lcm}(a,b)=\dfrac{a\times b}

  • 习题2-6 求阶乘序列前N项和2022-08-15 13:04:00

    #include<stdio.h> double fact(int n); int main() { int i, n; double result; scanf("%d", &n); for(i=1; i<=n; i++){ result = fact(i); } printf("%.0f", result); return 0; } double

  • 2022.8.12牛客小白补题2022-08-14 11:31:31

    B-Gaming_牛客小白月赛54 (nowcoder.com) 先把所有区间的权值加起来,考虑从覆盖住的区间中找一个不被覆盖的点,可以枚举删掉哪个点,删掉这个点造成的权值损失可以通过差分前缀和来得到。 const int N=1e6+5; typedef long long ll; int n,m; ll s[N]; ll tot; int main(){ scanf("%

  • YbtOJ 递推算法 做题记录2022-08-12 22:03:31

    例题 1 错排问题 \(f_i\) 表示前 \(i\) 个数的错排。易得递推式为 \(f_i=(i-1)\times(f_{i-1}+f_{i-2})\)。 code #include<bits/stdc++.h> #define int long long using namespace std; int n,f[25]; signed main() { scanf("%lld",&n); f[1]=0,f[2]=1; for(int i=

  • c语言中的do while循环语句2022-08-12 01:01:49

      001、 #include <stdio.h> int main(void) { int i; do { int random; printf("random = "); scanf("%d", &random); if (random % 2) { puts("odd");

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有