- 博客(9)
- 收藏
- 关注
原创 杭电oj2019-2024
2019数列有序 #include<iostream> #include<stdio.h> using namespace std; int main() { int n,m; int a[101],b[101]; while(cin>>n>>m) { if(n==0&&m==0) break; int c = 0; for(int i=0;
2021-02-20 12:42:51
140
原创 杭电oj2016-2018
2016数据的交换输出 #include<iostream> #include<stdio.h> using namespace std; int main() { int n; int a[100]; while(cin>>n) { if(n==0) { break; } int m=0; for(int i=0;i<n;i++) {
2021-02-09 22:21:34
118
原创 杭电oj2013-
2013蟠桃记 #include<iostream> #include<stdio.h> using namespace std; int main() { int n; while(cin>>n) { int s=1; for(int i=2;i<=n;i++) { s=s*2+2; } cout<<s<<endl; }
2021-02-08 20:30:10
170
原创 杭电oj2010-2012
2010水仙花数 #include<iostream> using namespace std; int main() { int m, n, i, a, b, c, p; while (cin >> m >> n) { p = 0; for (i = m;i <= n;i++) { a = i / 100; b = i / 10 % 10; c
2021-02-07 17:11:04
106
原创 杭电oj100题-2006-2009
杭电oj100题 2006求奇数的乘积 在这里插入代码片#include <iostream> //#include<stdlib.h> #include<stdio.h> using namespace std; int main() { int n; int a[100],sum; while(scanf("%d",&n)!=EOF) { sum=1; for(int i=0;i<n;i+
2021-01-30 21:37:52
178
原创 leetcode剑指offer09-用两个栈实现队列
用两个栈实现一个队列。队列的声明如下,请实现它的两个函数 appendTail 和 deleteHead ,分别完成在队列尾部插入整数和在队列头部删除整数的功能。(若队列中没有元素,deleteHead 操作返回 -1 ) 示例 1: 输入: [“CQueue”,“appendTail”,“deleteHead”,“deleteHead”] [[],[3],[],[]] 输出:[null,null,3,-1] 示例 2: 输入: [“CQueue”,“deleteHead”,“appendTail”,“ap
2021-01-30 14:23:27
164
原创 leetcode栈问题-155最小栈
设计一个支持 push ,pop ,top 操作,并能在常数时间内检索到最小元素的栈。 push(x) —— 将元素 x 推入栈中。 pop() —— 删除栈顶的元素。 top() —— 获取栈顶元素。 getMin() —— 检索栈中的最小元素。 示例: 输入: [“MinStack”,“push”,“push”,“push”,“getMin”,“pop”,“top”,“getMin”] [[],[-2],[0],[-3],[],[],[],[]] 输出: [null,null,null,null,-3,
2021-01-29 21:39:50
121
原创 由抽签问题谈谈时间复杂度
你的朋友提议玩一个游戏:将写有数字的 n个纸片放入口袋中,你可以从口袋中抽取 4次纸 片,每次记下纸片上的数字后都将其放回口袋中。如果这 4个数字的和是 m,就是你赢,否 则就是你的朋友赢。你挑战了好几回,结果一次也没赢过,于是怒而撕破口袋,取出所有纸 片,检查自己是否真的有赢的可能性。请你编写一个程序,判断当纸片上所写的数字是 k 1 , k 2 , …, k n 时,是否存在抽取 4次和为 m...
2018-12-12 20:27:54
235
原创 codewars Grasshopper - Summation题解
Summation Write a program that finds the summation of every number from 1 to num. The number will always be a positive integer greater than 0. For example: summation(2) -&amp;gt; 3 1 + 2 summation(8) -&amp;gt...
2018-12-09 19:29:39
554
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅