- 博客(20)
- 收藏
- 关注
原创 方格填数
方格填数如下的10个格子+--+--+--+||||+--+--+--+--+|||||+--+--+--+--+||||+--+--+--+(如果显示有问题,也可以参看【图1.jpg】)填入0~9的数字。要求:连续的两个数字不能相邻。(左右、上下、对角都算相邻)一共有多少种可能的填数方案?请填写表示方案数目的...
2019-03-17 21:01:12
118
原创 生成元
如果x加上x的各个数字之和得到y,就说x是y的生成元。求最小生成元。 这里如果找一个数只需要进行N-1次遍历,这里的思想是先找到所有数,可大大节省时间复杂度。#include<stdio.h>#include <cstring>#define maxn 10100int ans[maxn];int main(){ int T,n; memset...
2019-02-14 21:31:02
1056
原创 猜数字游戏的提示
猜数字游戏的提示实现一个经典“猜数字”游戏。给定答案序列和用户猜的序列,统计有多少数字位置正确(A),有多少数字在两个序列都出现过但位置不对(B)。 输入包含多组数据。每组输入第一行为序列长度n,第二行是答案序列,接下来是若干猜测序列,猜测序列全0时该组数据结束。n=0时输入结束。样例输入: 4 1 3 5 5 1 1 2 3 4 3 3 5 6 5 5 1 6 1 3 5 ...
2019-02-14 21:06:20
396
原创 子序列的和
题目描述:求1/n^2+1/(n+1)^2......1/m^2,以n=m=0结束#include <iostream>#include <iomanip> //头文件using namespace std;/* run this program using the console pauser or add your own getch, system("...
2019-01-15 21:13:02
300
原创 十六进制转八进制
问题描述 给定n个十六进制正整数,输出它们对应的八进制数。输入格式 输入的第一行为一个正整数n (1<=n<=10)。 接下来n行,每行一个由0~9、大写字母A~F组成的字符串,表示要转换的十六进制正整数,每个十六进制数长度不超过100000。输出格式 输出n行,每行为输入对应的八进制正整数。 【注意】 输入的十六进制数不会有前导0,比如012A。 输出的八...
2018-12-02 10:56:29
279
原创 等差素数列
#include <iostream>#include <cmath>#include <vector>using namespace std;vector<int>arr;/* run this program using the console pauser or add your own getch, system("pause") or input loop */bool Prime(int n){ if(n==2)
2018-11-30 11:39:58
242
1
转载 关于蛇形填数
蛇形填数的核心就是转向,while(x+1<n&&!a[x+1][y]) a[++x][y]==++count;每一个方向,都有临界转向范围即x+1<n 和下一个数组内是否有数值。类似的,矩形环绕和三角环绕, #include <stdio.h> main() { int n,a[10][10]={0},i=...
2018-10-30 17:26:03
77
原创 笨小熊
笨小熊时间限制:2000 ms | 内存限制:65535 KB难度:2输入第一行数据N(0<N<100)表示测试数据组数。每组测试数据输入只有一行,是一个单词,其中只可能出现小写字母,并且长度小于100。输出每组测试数据输出共两行,第一行是一个字符串,假设输入的的单词是Lucky Word,那么输出“Lucky Word”,否则输出“No Answer”;...
2018-10-30 17:22:49
130
原创 没错,这都是套路,
整除个数时间限制:3000 ms | 内存限制:65535 KB难度:1输入输入包含多组数据每组数据占一行,每行给出两个正整数n、b。输出输出每组数据相应的结果。样例输入2 15 310 4样例输出212来源自编上传者mix_math描述1、2、3… …n这n(0<n<=1000000000)个数中有...
2018-10-29 16:13:56
130
转载 谁获得了最高奖学金
一开始想着用结构体方便,确实很方便而且也很整洁,但是最后在寻找最大值时没有用到strcpy(h,f); //h[20]为获得最高奖学金的学生姓名;导致最后超时并且运行出错,很多时候逻辑上想是没有错,但运行时总会出错。证明一个道理,,,在没有逼格之前就谦虚学习别人也是好事。#include <stdio.h>#include <stdlib.h>struct Std...
2018-10-26 16:11:46
136
转载 6174问题
#include <iostream>#include<algorithm>using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char*...
2018-10-25 22:10:39
126
转载 精挑细选(利用结构体)
#include<stdio.h> #include<stdlib.h> struct Node { int x; int y; int z; }m[1000]; int cmp(const void *p1,const void *p2) { struct Node *c=(Node *)p1; struc...
2018-05-09 20:14:19
688
原创 关于进制相应的格式符表示
#include <stdio.h>#include <stdlib.h>int main(int argc, char *argv[]) {int a,b,n;char c;scanf("%d",&n);while(n--){ scanf("%x%c%x",&a,&c,&b); printf("%o\n",c=='+'?a+b:
2018-05-05 22:42:50
454
原创 关于矩阵的个数问题
#include <stdio.h>#include <stdlib.h>int main(int argc, char *argv[]) {long m,n,c;while(scanf("%lld%lld",&m,&n)!=EOF){ c=m*(m+1)/2*n*(n+1)/2; printf("%lld\n",c);} return 0;}矩阵问...
2018-05-04 10:43:46
398
原创 关于蛇形填数
蛇形填数的核心就是转向,while(x+1<n&&!a[x+1][y]) a[++x][y]==++count;每一个方向,都有临界转向范围即x+1<n 和下一个数组内是否有数值。类似的,矩形环绕和三角环绕,#include <stdio.h> void main() { int n,a[10][10]={0},i=1,c=1; ...
2018-05-01 15:18:58
137
转载 n-1位
#include<cstdio>//最优程序 int main() { int n,m; scanf("%d",&n); while(n--) { scanf("\n%*c%d",&m);//%*转换格式符的作用是跳过相对应的输入项,也可以换成getch...
2018-04-29 23:25:34
92
原创 无主之地1
输出各个区域的统计结果(不要求排序)关于无主之地代码本身很简单,#include<stdio.h>#include<string.h>#include<stdlib.h> int main(){ int m,n,i,j; int a[105],b[105]; memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); ...
2018-04-29 21:32:30
572
原创 关于公约数与公倍数问题
#include <stdio.h>#include <stdlib.h>/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char *argv[]) {int n,i,j,k,a,b;s...
2018-04-29 21:28:19
122
原创 关于限定输入位数
小学生算法#include <stdio.h>#include <stdlib.h>int main(){int m,n,i; char a[5],b[5];//通常用数组存入数据,更方便快捷// while (~scanf ("%d%d",&m,&n)) { int cnt=0,q=0,t=0;//此时用两个累积符号是需要考虑到当十位进位与个...
2018-04-25 11:31:34
1795
原创 关于字符串反向输出问题
#include<stdio.h>#include<string.h>int main(){ int i,n,j; char a[40],ch; scanf("%d",&n); getchar();//用getchar()消除上一级输入的回车字符// while(n--) { a[0]=0; //scanf("%s",a);此处不用scan...
2018-04-24 21:51:40
225
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人