我喜欢给自己压力,必须得定一个很高的目标,逼自己朝着这个目标前进,不管会不会实现,都是一个动力。 ----喻言
链接:https://ac.nowcoder.com/acm/problem/15727
来源:牛客网
题目描述
In the latest activity in the game, you want to find the most efficient way to collect at least Z coins. There is a battle in this game. Everytime you finish the battle, you can get N coins. To make the activity more interesting, you can spend X coins to exchange a special card. If you carry K cards in the battle, you can get N+K×YN + K \times YN+K×Y coins when you finish the battle rather than only N coins. So how many times will you finish the battle at least?
输入描述:
\emph{Input contains multiple but no more than 10 test cases}, the first line of input is an integer T, the number of test cases.
In the following T lines each line has for integers N,X,Y,ZN, X, Y, ZN,X,Y,Z (1≤N,X,Y,Z≤1091 \le N, X, Y, Z \le 10^91≤N,X,Y,Z≤109), and the meaning of them have been mentioned.
输出描述:
For each case, please output the minimum times you should finish the battle.
示例1
输入
复制
1 1 10 1 100
输出
复制
39
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#include<climits>//INT_MAX
#define PP pair<ll,int>
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3fll
#define dinf 1000000000000.0
typedef long long ll;
using namespace std;
int const N=100000+10;
int const mod=1e9+7;
const int maxn=10000000+10;
ll T,n,x,y,z;
int main() {
cin>>T;
while(T--)
{
cin>>n>>x>>y>>z;
ll ct=0,sum=0,jg=(ll)1e18;
while(1){
if(sum>=jg)
break;
jg=min(jg,sum+(z-ct+n-1)/n);
if (ct>=x) {
n+=y*(ct/x);
ct%=x;
}
else if (ct<x) {
sum+=(x-ct+n-1)/n;
ct+=(x-ct+n-1)/n*n;
continue;
}
}
cout<<jg<<endl;
}
return 0;
}
链接:https://ac.nowcoder.com/acm/problem/15757
来源:牛客网
题目描述
《扫雷》是一款大众类的益智小游戏,于1992年发行。游戏目标是在最短的时间内根据点击格子出现的数字找出所有非雷格子,同时避免踩雷,踩到一个雷即全盘皆输。当某个位置为数字的时,代表它周围的八连通区域中有对应数量的雷。
kirai获取了简化版扫雷(没有标记雷的小旗)的后台数据(后台数据包括所有数字和雷的位置),转换为一个n*m(1≤n, m≤500)的矩阵并对格子类型做了如下标记:
雷被标记为'*';
点开的空白区域标记为'0';
未点开的空白区域标记为'.';
数字1~8代表周围有多少雷;
kirai非常笨,他希望你帮他完成这样的任务:
给定k(1≤k≤min(可扫位置数, 10))个位置坐标和扫雷游戏的后台数据,输出点开指定位置序列后游戏的结果,初始时游戏中没有点开任何位置。
注:数据保证扫雷过程中不会重复点击已扫位置。
输入描述:
输入样例有多组,全部是正整数。首先输入样例组数T(T≤10)。 接下来输入T组数,每组数据第一行包括四个正整数n,m,k(1≤n, m≤500, 1≤k≤min(可扫位置数, 10))分别表示地图的行、列数和即将点开的位置数。紧接着是一个n*m的矩阵,代表扫雷的后台数据,。 矩阵后是k个整数对xi, yi(1≤i≤k, 1≤xi≤n, 1≤yi≤m),表示依次点开的位置。
输出描述:
如果某一步踩到雷,输出"Game over in step x"(不包括引号",表示第x步踩中雷);未踩到雷则根据扫雷的游戏规则更新,并输出最后一步结束后显示给kirai的矩阵。
示例1
输入
复制
1 5 5 3 2*11* *2111 22... *1... 11... 1 1 3 3 1 2
输出
复制
Game over in step 3
说明
2.... ..... ..... ..... ..... 2.... .2111 .2000 .1000 .1000 Game over in step 3
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#include<climits>//INT_MAX
#define PP pair<ll,int>
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3fll
#define dinf 1000000000000.0
typedef long long ll;
using namespace std;
int const N=100000+10;
int const mod=1e9+7;
const int maxn=10000000+10;
char s[510][510];
int T,m,n,k,x,y;
int main()
{
cin>>T;
while(T--)
{
int fg=1;
cin>>n>>m>>k;
for(int i=1;i<=n;i++)
cin>>s[i]+1;
for(int i=1;i<=k;i++)
{
cin>>x>>y;
if(!fg)
continue;
if(s[x][y]=='.')
s[x][y]='0';
if(s[x][y]=='*')
{
cout<<"Game over in step "<<i<<endl;
fg=0;
}
}
if(fg)
{
for(int i=1;i<=n;i++)
cout<<s[i]+1<<endl;
}
}
return 0;
}
链接:https://ac.nowcoder.com/acm/problem/15756
来源:牛客网
题目描述
Kirai聊天的时候非常喜欢发“233”,“233”来源于猫扑表情第233号,是一张捶地大笑的表情。
Kirai每当看到很好玩的消息的时候总会回一串“2333...”。
Kirai其实十分高冷,他发现了这个问题。为了不希望别人立刻知道他在笑,他决定将两个“233..”乘在一起发出去。
输入描述:
输入样例有多组,全部是正整数。首先输入样例组数T(T≤1500)。 接下来输入T组数,每组数字由两个233串组成,每个233串长度3≤n≤50。 数据保证每个233串必然会有一个2作为开头,并且3的数量≥2。
输出描述:
两个233串的乘积。
示例1
输入
复制
2 233 233 23333333333333333333333333333333333333333333333333 23333333333333333333333333333333333333333333333333
输出
复制
54289 544444444444444444444444444444444444444444444444428888888888888888888888888888888888888888888888889
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#include<climits>//INT_MAX
#define PP pair<ll,int>
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3fll
#define dinf 1000000000000.0
typedef long long ll;
using namespace std;
int const N=100000+10;
int const mod=1e9+7;
const int maxn=10000000+10;
int t,cdn,cdx,mi,mx;
char n[60],x[60];
int main()
{
scanf("%d",&t);
for(int i=0;i<t;i++)
{
scanf("%s%s",n,x);
cdn=strlen(n)-2;
cdx=strlen(x)-2;
mi=cdx<cdn?cdx:cdn;
mx=cdx>cdn?cdx:cdn;
printf("5");
for(int j=0;j<mi;j++)
printf("4");
if(cdx==cdn)
printf("2");
else
{
printf("3");
for(int j=0;j<mx-mi-1;j++)
printf("6");
printf("5");
}
for(int j=0;j<mi;j++)
printf("8");
printf("9\n");
}
return 0;
}