php电子商务网站开发,线下营销活动有哪些,公司网页建立,设置网站首页icebound的账单 题目描述
icebound从小就有记账的习惯。又到了月末icebound统计资金状况的时候。icebound每个月除了不停的挥霍以外#xff0c;有时他会良心发现#xff0c;勤工俭学#xff0c;因此会有一些微薄的收入。然而icebound数学不好#xff0c;需要你来帮助他统计…icebound的账单 题目描述
icebound从小就有记账的习惯。又到了月末icebound统计资金状况的时候。icebound每个月除了不停的挥霍以外有时他会良心发现勤工俭学因此会有一些微薄的收入。然而icebound数学不好需要你来帮助他统计他本月的资金状况。
你将会得到一份icebound的账单一共有 n 行整数其中正数表示icebound打工挣来的收入负数表示icebound消费的支出。数据保证不会出现 0 。
如果icebound本月总收入大于总支出请你输出“icebound is happy.”如果本月总收入等于总支出请你输出“icebound is ok.如果总收入小于总支出请你输出icebound is sad.。
输入描述
第一行有一个正整数nn代表账单有nn行。
接下来有nn行每行一个整数第i1i1行整数a_iai。
1 \leq n \leq 10001≤n≤1000\left| a_i \right|\leq 1000∣ai∣≤1000, a_i \neq 0ai≠0
输出描述
输出一行。如果icebound本月总收入大于总支出请你输出“icebound is happy.”如果本月总收入等于总支出请你输出“icebound is ok.如果总收入小于总支出请你输出icebound is sad.。
样例输入
2
100
-100
样例输出
icebound is ok.
思路简单分类不解释
#includebits/stdc.h
using namespace std;
long long sum 0;int main()
{int n,k;cin n;while(n--){scanf(%d, k);sum k;}if(sum 0)cout icebound is happy. endl;else if (sum 0)cout icebound is sad. endl;elsecout icebound is ok. endl;return 0;
} 520
题目描述
“又到了五月了呢”icebound望着五月的天空眼角流出了泪痕。那一年icebound还是一个懵懂的少年。那一年她还是一个青涩纯真的少女。在那一次偶然的相遇之中他们之间擦出了爱情的火花。他们欢笑着奔跑着他们展望着美好的未来向往着幸福的明天。她像 icebound 心海中的灯塔像icebound 头顶上的星辰即使在海里浮沉即使在夜里摸爬心中也不会感到迷茫感到阴寒。他们努力奋进向着六月的那一站前行。可是美好总是短暂的。那海上的灯塔不再发出温情的光亮那天空中的星辰不再绽放出温柔的色彩。那一站到达了icebound 得到了终点但icebound 永远失去了她也失去了他的心。
”侯门一入深似海从此萧郎是路人“
今天是2018年5月20日又是一年的520。这一天icebound不小心读到上面的诗icebound沉思着回想起与她曾经的快乐时光icebound留下了nn滴眼泪。icebound的每滴眼泪都带有太多的伤感之情了以至于每滴眼泪都会感染到其他的生物使得许多生物都一起掉下了眼泪。kk通过观察得知当icebound流出nn滴眼泪时所有生物产生的眼泪总数为2^n。现在kk需要你帮助他写一个程序计算当icebound流出nn滴眼泪时所有生物产生的眼泪总数PP对 2018052020180520 取模。
输入描述
一个正整数nn代表icebound留下眼泪的个数。1 \leq n \leq 2 \times 10^91≤n≤2×109
输出描述
一个正整数PP代表所有生物产生的眼泪总数对 2018052020180520 取模。
样例输入
1
样例输出
2
思路n太大写一个快速幂
#include bits/stdc.h
using namespace std;
long long int mi(long long int a,long long int b,long long int m)
{long long int ans1;aa%m;while(b!0){if(b1)ansans*a%m;b 1;aa*a%m;}return ans%m;
}
int main()
{int n;cinn;int sum mi(2,n,20180520)%20180520;coutsum;return 0;
}神殿
题目描述
icebound通过勤工俭学攒了一小笔钱于是他决定出国旅游。这天icebound走进了一个神秘的神殿。神殿由八位守护者守卫总共由6464个门组成每一道门后都有一个迷宫迷宫的大小均为100 \times 100100×100。icebound在迷宫中总共耗时TT小时消耗食物KK公斤。历经千辛万苦之后icebound终于穿越了迷宫到达了神殿的中心。神殿的中心有一个宝箱。宝箱上显示有两个正整数ll和rr。icebound苦思冥想终于发现一些打开宝箱的线索。你需要找到一个数PP它具有一个美妙的性质它是[l,r][l,r]中所有数的二进制表示里11的个数最多的一个数。如果你发现了这个美妙的数字你就可以打开宝箱获得巨额财富。
比如[4,8][4,8]中
4: 0100
5: 0101
6: 0110
7: 0111
8: 1000二进制表示中11的个数最多的数是77它含有33个11。
输入描述
输入一行两个正整数ll和rr用空格隔开代表神殿中宝箱上显示的数。
1 \leq T 2^{31}1≤T231,
1 \leq K \leq 10^51≤K≤105,
1 \leq l \leq r \leq 2 \times 10^{9}1≤l≤r≤2×109
输出描述
一个十进制数P代表满足条件的解。如果有多个P满足条件输出最小的P。
样例输入
4 8
样例输出
7
思路
求区间内二进数中1最多的那个数是多少。
求不超过r的位或和。
比如
0 1 1
1 0 0
----------
1 1 1
有一个1就为1
#includebits/stdc.h
using namespace std;
int main()
{long long l,r,i;scanf(%lld %lld,l,r);for(il;ir;i)if((i|i1)r)break;printf(%lld,i);
}Mex Query
题目描述
Give nn non-negative integers, please find the least non-negative integer that doesn’t occur in the nn numbers.
输入描述
The first line is an integer TT, representing the number of test cases.
For each test case:
The first line of each test case is an integer nn.
The second line of each test case are nn non-negative integers a_iai.
T \leq 10T≤10
n \leq 2 \times 10^5n≤2×105
0 \leq a_i 2^{31}0≤ai231
输出描述
or each test case, output a line with the answer.
样例输入
2
4
4 0 1 3
2
1 1样例输出
2
0
思路找出序列里第一个没有出现过的数排序然后本数减前一个数大于一就说明相差大于一就找到了那个确实的数了。
#includebits/stdc.h
using namespace std;
int arr[200005];
int main(){int tk;cin t;while(t--){int n;scanf(%d, n);for(int i 1; i n; i)scanf(%d, arr[i]);sort(arr1, arrn1);arr[0] -1;for(int i 1; i n; i){if(arr[i] - arr[i-1] 1){printf(%d\n, arr[i-1]1);break;}}}return 0;
}icebound的商店
题目描述
icebound在得到神殿的宝藏之后开了一家神秘的商店。你来到了商店发现慷慨的icebound搞了TT次促销活动。在每次促销活动中icebound都会想出一个他喜欢的数字如果你买的商品的总价刚好等于icebound喜欢的数字那么你就可以免费得到这些商品。
icebound的商店里一共有 1515 件商品商品的价格和这家商店一样神秘第一件商品的价格是 11 元第二件商品的价格是 22元设第nn件商品的价格为w_nwn元则w_n w_{n-1} w_{n-2} (3 \leq n \leq 15)wnwn−1wn−2(3≤n≤15)。
如果在某次活动中icebound喜欢的数字是 44那么共有 44 种购买方案
1. 买 4个 第一种商品
2. 买 2个 第一种商品 和 1个 第二种商品
3. 买 2个 第二种商品
4. 买 1个 第一种商品 和 1个 第三种商品请你算出共有多少种方案可以免费购物方案数对10000000091000000009(10^991099)取模。
输入描述
第一行给出一个整数TT表示icebound搞了TT次活动。
接下来的TT行每行给出一个正整数xx表示在这次活动中icebound喜欢的数字。
1 \leq T \leq 30001≤T≤3000
1 \leq x \leq 30001≤x≤3000
输出描述
输出TT行每行输出一个正整数。
第ii行的正整数表示在第ii次活动中免费购物的方案数方案数对10000000091000000009(10^991099)取模。
样例输入
3
5
20
30
样例输出
6
134
509
思路动态规划背包求方法数的变形物品为斐波那契数列前几项先求出来。然后转移方程为dp[j](dp[j]dp[j-fib[i]])%MOD
总结的技巧一般把式子的max变为sum即可。
#include bits/stdc.h
using namespace std;
typedef long long ll;
const int N 2e6;
const int MOD 1e9 9;
int fib[50];
int dp[3005];
inline void init() //前15项商品
{fib[1] 1, fib[2] 2;for(int i 3; i 15; i) fib[i] fib[i - 1] fib[i - 2];
}
int main()
{init();int T, x;scanf(%d, T);while(T--) {scanf(%d, x);memset(dp, 0, sizeof dp);dp[0] 1;for(int i 1; i 15; i)for(int j fib[i]; j x; j)dp[j] (dp[j] dp[j - fib[i]]) % MOD;//情况求和printf(%d\n, dp[x] % MOD);}return 0;
}跑图
题目描述
跑图是RPG游戏中很烦躁的事情。玩家需要跑到距离他最近的传送点的位置。现在给你一张N \times MN×M的方格图每个方格中数值00表示为平地数值11表示为传送点你的任务是输出一张N \times MN×M的矩阵Matrix_{xy}Matrixxy表示从(x,y)(x,y)到距离它最近的传送点的距离。 这里的距离是曼哈顿距离(x_1,y_1) \rightarrow(x_2,y_2)(x1,y1)→(x2,y2) 的距离为|x_1-x_2||y_1-y_2|∣x1−x2∣∣y1−y2∣。
输入描述
第一行有两个数n,mn,m。接下来nn行每行mm个数。
数据保证至少有一个传送点。
1 \leq n \leq 5001≤n≤5001 \leq m \leq 5001≤m≤500
输出描述
nn行每行mm个数表示某个点到离它最近的传送点的距离。
样例输入
2 3
0 0 0
1 0 1
样例输出
1 2 1
0 1 0思路直接把传送点的位置放进一个队列里然后跑BFS即可每个点只需要被访问一次到传送点的的距离也都是最近的
#include bits/stdc.h
using namespace std;const int inf 0x3f3f3f3f;
const int maxn 500 5;
int arr[maxn][maxn];
int vis[maxn][maxn];
int dir[4][2] {-1, 0, 0, 1, 1, 0, 0, -1};
int dis[maxn][maxn];
int n, m;
struct Node{int x, y, dis;
};bool check(int x, int y){if(x 0 x n y 0 y m){return true;}return false;
}int main(){int k;cin n m;memset(dis, inf, sizeof dis);queueNode q;for(int i 0; i n; i){for(int j 0; j m; j){scanf(%d, k);arr[i][j] k;if(k 1){Node node {i, j, 0};q.push(node);dis[i][j] 0;}}}while(q.size()){Node tmp q.front();q.pop();int tx tmp.x;int ty tmp.y;int ts tmp.dis;for(int i 0; i 4; i){if(check(txdir[i][0], tydir[i][1])){int dx tx dir[i][0];int dy ty dir[i][1];if(dis[dx][dy] ts 1){dis[dx][dy] ts 1;Node t {dx, dy, ts1};q.push(t);}}}}for(int i 0; i n; i){for(int j 0; j m-1; j){printf(%d , dis[i][j]);}printf(%d\n, dis[i][m-1]);}return 0;
} K Multiple Longest Commom Subsequence
题目描述
KK has two sequences, AA and BB, and wants to find the kk multiple longest common subsequence.A sequence SS is a kkmultiple common subsequence of AA and BB if and only if it satisfies the following conditions: SS is a subsequence of AA and is a subsequence of BB. (A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.) The length of SS is t\times kt×k where tt is a nonnegative integer. The first element of SS is S[1]S[1]. If we divide the sequence into tt groups with the iith group containing S[(i - 1) \times k j] (1 \leq j \leq k)S[(i−1)×kj](1≤j≤k), for every element gg, it shares the same value with other elements that are in the same group which gg belongs to.
For example, [1, 1, 2, 2][1,1,2,2] is a double common subsequence of [1, 2, 3, 1, 2, 3, 2][1,2,3,1,2,3,2] and [1, 3, 1, 2, 2][1,3,1,2,2]. KK wants to know the maximum length of such sequence.
输入描述
The first line is an integer TT, denoting the number of test cases.
For each test case, the first line are three integers kk , nn, mm, denoting the kind of subsequence, the length of AA and the length of BB.
The second line are nn integers A_1 \sim A_nA1∼An, representing the elements of AA.
The third line are mm integers B_1 \sim B_mB1∼Bm, representing the elements of BB.
1 \leq T \leq 101≤T≤10 , 1\leq k, n, m \leq 10^31≤k,n,m≤103, 1\leq A_i, B_i \leq 10^31≤Ai,Bi≤103.
输出描述
For each test case, output a line with the maximum length of kk multiple common subsequence.
样例输入
3
1 4 5
1 2 3 4
4 1 3 2 4
2 8 7
1 1 2 2 3 3 4 4
1 2 3 1 2 3 3
3 9 9
1 1 1 2 2 2 3 3 3
1 2 3 1 2 3 1 2 3
样例输出
3
4
3
题意最长公共子序列要求序列每个元素重复k次比如1122重复两次111222重复三次。
输入两个字符串和k输出长度。
最长公共子序列的一个变形。。。
动态规划。设dp[i][j]表示a串处理到i位置b串处理到j位置的答案。预处理出从a串i位置向前数第k个与i位置数 字相同的位置p[i]用相同方式处理出B串的q[i]。 则转移方程为dp[i][j]max(dp[i-1][j],dp[i][j-1],dp[i-p[i]][j-q[j]]k),其中第三种转移必须在a[i]b[j]而且p,q都存在的情况下转移。
#include bits/stdc.h
using namespace std;
int k,n,m,dp[1005][1005];
int a[1005],b[1005];
int pa[1005]{0},pb[1005]{0};
queueint q[1005];
int main()
{int ak; cinak;while(ak--){for(int i1;in;i)while(!q[i].empty()) q[i].pop();scanf(%d%d%d,k,n,m);memset(dp,0,sizeof(dp));memset(pa,0,sizeof(pa));memset(pb,0,sizeof(pb));for(int i1;in;i) cina[i];for(int i1;im;i) cinb[i];for(int i1;in;i){q[a[i]].push(i);if(q[a[i]].size()k){pa[i]q[a[i]].front();q[a[i]].pop();}}for(int i1;in;i)while(!q[i].empty()) q[i].pop();for(int i1;im;i){q[b[i]].push(i);if(q[b[i]].size()k){pb[i]q[b[i]].front();q[b[i]].pop();}}for(int i1;in;i){for(int j1;jm;j){dp[i][j]max(dp[i-1][j],dp[i][j-1]);if(a[i]b[j] pa[i]!0 pb[j]!0)dp[i][j]dp[pa[i]-1][pb[j]-1]k;}}printf(%d\n,dp[n][m]);}return 0;
} Nim Game
总感觉复制到这里符号就不对了原题网址http://newoj.acmclub.cn/problems/2013
题目描述
Description
Nim is a mathematical game of strategy in which two players take turns removing objects from distinct heaps. On each turn, a player must remove at least one object, and may remove any number of objects provided they all come from the same heap [From Wikipedia, the free encyclopedia]. The goal of the game is to avoid being the player who doesn’t have any object to remove. The player who remove the last project is the winner.
Now KK and TT are playing Nim game with the optimal strategy. There are nn heaps of stones. The number of stones in ii -th heap is a_iai. They play this game mm times, and KK is the player making the first move. During the ii -th time they play the game on the heaps whose index in interval [l_i,r_i][li,ri]. KK wants to know whether he has a winning strategy or not.
输入描述
Input
The input consists of several test cases. The first line of the input gives the number of test cases, T(1\le T\le 10^3)T(1≤T≤103).
For test case, the first line contains two integers n(1\le n\le 10^6)n(1≤n≤106) and m(1\le m\le 10^6)m(1≤m≤106), representing the number of heap of stones and the game times.
The second line contains nn positive integers a_1,a_2,\cdots,a_n(1\le a_i\le 10^9)a1,a2,⋯,an(1≤ai≤109), representing The number of stones in ii-th heap.
In the next mm lines, each line contains two integers l_i,r_ili,ri, which means the $i: KaTeX parse error: $ within math mode$th game is played on the interval [l_i,r_i][li,ri].
It’s guaranteed that \sum n\le 2\times 10^6∑n≤2×106 and \sum m\le 2\times 10^6∑m≤2×106
输出描述
Output
For each test case, let f_ifi represents the answer of the ii th game.
If KK has a winning strategy in the ii th game then f_i1fi1, otherwise f_i0fi0. Please output \sum f_i*2^{m-i}\ mod\ 10^97∑fi∗2m−i mod 1097in which 1\le i\le m1≤i≤m
样例输入
3
2 1
1 1
1 2
2 1
1 2
1 2
3 2
1 2 2
1 2
2 3样例输出
0
1
2
思路 和普通Nim游戏不同在于每一次会给出对应的堆区间
比如现在有5堆每一堆个数分别为1 2 3 4 5选择1 3代表选择1 2 3这三堆为本轮的堆数 测试这区间的堆数的异或值是否为0如果为0必败否则必胜 需要记录一个前缀异或和数组优化时间
每次给出[l,r]只需要pre[r]^pre[l-1]即可
#include bits/stdc.h
using namespace std;
typedef long long ll;
const int N 2e6;
const int MOD 1e9 7;
int arr[N 5];
ll pre[N 5];
ll powmod(ll a, ll b)
{ll res1;a % MOD;while(b){if(b 1) res res * a % MOD;aa * a % MOD;b 1;}return res;
}
int main(void)
{int T, n, m, l, r;scanf(%d, T);while(T--) {pre[0] 0;scanf(%d %d, n, m);for(int i 1; i n; i) {scanf(%d, arr i);pre[i] pre[i - 1] ^ arr[i]; //记录异或前缀和}ll sum 0;for(int i 1; i m; i) {scanf(%d %d, l, r);if(pre[r] ^ pre[l - 1]) {//一个数如果异或两次等于没有异或过比如1^2^3^21^3sum powmod(2, m - i);sum % MOD; //记得取模}}printf(%lld\n, sum % MOD);}return 0;
}
注这个题是看yzx大佬思路的。 剩下的暂时不会做啦。。。。