Wannafly交流赛1(施工中)
A.有理数
签到题:直接用floor函数就行了,详细看代码
#define debug
#include<stdio.h>
#include<math.h>
#include<cmath>
#include<queue>
#include<stack>
#include<string>
#include<cstring>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<functional>
#include<iomanip>
#include<map>
#include<set>
#define f first
#define s second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll>PLL;
typedef pair<int,ll>Pil;
const ll INF = 0x3f3f3f3f;
const double inf=1e8+100;
const double eps=1e-8;
const ll maxn =1e3+200;
const int N = 1e4+10;
const ll mod=1e9+7;
//define //--solve
void solve() {
int i,j,tt=1;
cin>>tt;
while(tt--){
ll p,q;
ll tmp;
cin>>p>>q;
if(p%q==0){
tmp=floor(p*1.0/q)-1;
}
else tmp=floor(p*1.0/q);
cout<<tmp<<endl;
}
} int main() {
ios_base::sync_with_stdio(false);
#ifdef debug
freopen("in.txt", "r", stdin);
// freopen("out.txt","w",stdout);
#endif
cin.tie(0);
cout.tie(0);
solve();
/*
#ifdef debug
fclose(stdin);
fclose(stdout);
system("out.txt");
#endif
*/
return 0;
}
B。硬币,实际上50,10都是有5的倍数,所以可以直接吧50,10元的看成是数个5元构成硬币,那问题就容易了,假设一个物品要v元,remain=v%5,就为剩下的还要给少个硬币才能凑够买一个v元物品,然后k=5-remain,这这个k其实就是找回的1元硬币数,详细看代码
#define debug
#include<stdio.h>
#include<math.h>
#include<cmath>
#include<queue>
#include<stack>
#include<string>
#include<cstring>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<functional>
#include<iomanip>
#include<map>
#include<set>
#define f first
#define s second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll>PLL;
typedef pair<int,ll>Pil;
const ll INF = 0x3f3f3f3f;
const double inf=1e8+100;
const double eps=1e-8;
const ll maxn =1e3+200;
const int N = 1e4+10;
const ll mod=1e9+7;
//define
ll c[maxn];
//
ll gcd(ll a,ll b) {
return b==0?a:gcd(b,a%b);
}
//--solve
void solve() {
int i,j,tt=1;
cin>>tt;
ll c1,c2,c4,c3,v;
while(tt--){
ll ans=0ll,sum=0;
cin>>c1>>c2>>c3>>c4>>v;
sum=c2*5+c3*10+c4*50;
ll remain=v%5;
ll k=0ll;
if(remain){
k=5-remain;
v+=k;
}
ans=k*(sum/v)+c1;
cout<<ans<<endl;
}
} int main() {
ios_base::sync_with_stdio(false);
#ifdef debug
freopen("in.txt", "r", stdin);
// freopen("out.txt","w",stdout);
#endif
cin.tie(0);
cout.tie(0);
solve();
/*
#ifdef debug
fclose(stdin);
fclose(stdout);
system("out.txt");
#endif
*/
return 0;
}
C.腰带环
D.迷宫
比赛的时候用bfs,tle了,然后群里大佬说是用最小分割(听的一头雾水),然后今天看了别人博客的时候发现了跟我想法一样,而他的过的原因:数组没我只开的大。至于最小分割的,以后学了再补上。
分析:实际上就是让你求从上边或者右边到下边或者左边的最短路
#define debug
#include<stdio.h>
#include<math.h>
#include<cmath>
#include<queue>
#include<stack>
#include<string>
#include<cstring>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<functional>
#include<iomanip>
#include<map>
#include<set>
#define f first
#define s second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll>PLL;
typedef pair<int,ll>Pil;
const ll INF = 0x3f3f3f3f;
const double inf=1e8+100;
const double eps=1e-8;
const ll maxn =3e2+300;
const int N = 1e4+10;
const ll mod=1e9+7;
//define
struct node {
int x,y;
ll cost;
node(int x=0,int y=0,ll cost=0):x(x),y(y),cost(cost) {}
bool operator<(const node &a)const {
return cost>a.cost;
}
};
ll d[510][510];
ll mp[600][600];
int dir[4][2]= {0,1,1,0,0,-1,-1,0};
int t,n,m;
priority_queue<node>q;
//ok
bool ok(int x,int y) {
if(x>=1&&x<=n&&y>=1&&y<=m&&mp[x][y]!=0) {
return 1;
}
return 0;
}
//bfs
ll bfs() {
ll ans=-1ll;
while(!q.empty()) {
node now=q.top();
q.pop();
if(now.x==n||now.y==1) {
if(ans==-1)
ans=now.cost;
ans=min(ans,now.cost);
continue;
}
for(int i=0; i<4; i++) {
int xx=now.x+dir[i][0];
int yy=now.y+dir[i][1];
if(xx<1||yy<1||xx>n||yy>m||!mp[xx][yy])
continue;
if(mp[xx][yy]==-1) {
if(d[xx][yy]==-1||d[xx][yy]>now.cost) {
d[xx][yy]=now.cost;
q.push(node(xx,yy,now.cost));
// cout<<xx<<" "<<yy<<" "<d[xx][yy]<<endl;
}
} else {
if(d[xx][yy]==-1||d[xx][yy]>now.cost+mp[xx][yy]) {
d[xx][yy]=now.cost+mp[xx][yy];
q.push(node(xx,yy,d[xx][yy]));
// cout<<xx<<" "<<yy<<" "<d[xx][yy]<<endl;
}
}
}
}
return ans;
} //--solve
void solve() {
int i,j,tt=1;
// cin>>t>>n>>m;
scanf("%d%d%d",&t,&n,&m);
while(t--) {
for(i=1; i<=n; i++) {
for(j=1; j<=m; j++) {
// cin>>mp[i][j];
scanf("%lld",&mp[i][j]);
}
}
memset(d,-1,sizeof(d));
for(j=1; j<=m; j++) {
if(mp[1][j]) {
d[1][j]=(mp[1][j]==-1?0:mp[1][j]);
q.push(node(1,j,d[1][j]));
}
}
for(i=2; i<=n; i++) {
if(mp[i][m]) {
d[i][m]=(mp[i][m]==-1?0:mp[i][m]);
q.push(node(i,m,d[i][m]));
}
}
// for(i=1; i<=n; i++) {
// for(j=1; j<=m; j++) {
// cout<<mp[i][j]<<" ";
// }
// cout<<endl;
// }
printf("%lld\n",bfs());
}
} int main() {
// ios_base::sync_with_stdio(false);
#ifdef debug
freopen("in.txt", "r", stdin);
// freopen("out.txt","w",stdout);
#endif
// cin.tie(0);
// cout.tie(0);
solve();
/*
#ifdef debug
fclose(stdin);
fclose(stdout);
system("out.txt");
#endif
*/
return 0;
}
Wannafly交流赛1(施工中)的更多相关文章
- Wannafly交流赛1_B_硬币【数学】
Wannafly交流赛1_B_硬币[数学] 链接:https://www.nowcoder.com/acm/contest/69/B 来源:牛客网 题目描述 蜥蜴的生日快到了,就在这个月底! 今年,蜥 ...
- Wannafly交流赛1 _A_有理数 【水】
Wannafly交流赛1 A有理数 [水] 链接:https://www.nowcoder.com/acm/contest/69/A 来源:牛客网 题目描述 有一个问题如下: 给你一个有理数v,请找到 ...
- Wannafly交流赛1 B 硬币[数学思维/贪心]
链接:https://www.nowcoder.com/acm/contest/69/B来源:牛客网 蜥蜴的生日快到了,就在这个月底! 今年,蜥蜴的快乐伙伴之一壁虎想要送好多个1元硬币来恶整蜥蜴. 壁 ...
- Wannafly交流赛1 A 有理数[模拟/分类讨论]
链接:https://www.nowcoder.com/acm/contest/69/A来源:牛客网 题目描述 有一个问题如下: 给你一个有理数v,请找到小于v的最大有理数. 但这个问题的答案对于任意 ...
- 记:青岛理工ACM交流赛筹备工作总结篇
这几天筹备青岛理工ACM交流赛的过程中遇到了不少问题也涨了不少经验.对非常多事也有了和曾经不一样的看法, 一直在想事后把这几天的流水帐记一遍,一直没空直到今天考完C++才坐下来開始动笔.将这几天的忙 ...
- 青岛理工交流赛 H题 素数间隙
13110581088注销 素数间隙 Time Limit: 1000MS Memory limit: 262144K 题目描述 Neko猫是一个很喜欢玩数字游戏的会说话的肥猫,经常会想到很多很好玩的 ...
- 青岛理工ACM交流赛 J题 数格子算面积
数格子算面积 Time Limit: 1000MS Memory limit: 262144K 题目描述 给你一个多边形(用’\’和’/’表示多边形的边),求多边形的面积. 输入 第一行两个正整数h ...
- 西安活动 | 2019年1月13号 "拥抱开源, 又见.NET" 线下交流活动报名进行中
随着.NET Core的发布和开源,.NET又重新回到人们的视野..NET Core的下个3.0即将release,加入非常多的新功能,越来越拥抱变化,DevOps和Microservice的最佳实践 ...
- 丽泽普及2022交流赛day14
目录 A 题面 题解 B 题面 题解 C 题面 题解 D 题面 题解 A 题面 一个 \(1\dots n\) 的排列 \(p\) 和一个 \(1\dots n-1\) 的排列 \(q\) 满足 对排 ...
随机推荐
- JavaWeb中jsp九大内置对象 和四大作用域
九大内置对象为 page request response session exception config application out pageContext no 内置对象 类型 1 pag ...
- CentOS添加磁盘分区
(这里的磁盘在vmware workstation VM中添加) 1.关闭虚拟机,在虚拟机设置中添加一个硬盘,然后开启虚拟机. 2.使用fdisk -l命令查看,这时会发现一个为被使用的设备,有2G的 ...
- python做基本的图像处理
PIL是python中的图像处理类库,为python提供了基本的图像处理和基本操作.而PIL中最重要的就是Image模块,下面给出具体的例子来理解此模块. 读取一幅图像 我们用Image模块中的ope ...
- 编译器重复定义错误:error C2371: 'SIZE' : redefinition; different basic types
我们常常会定义自己工程用的数据类型,可能会与Windows的基本数据类型冲突. vs会报重复定义错误:error C2371: 'SIZE' : redefinition; different bas ...
- 促进客户转化,提高客单价!酷客多小程序发布版本V1.0.9!
商户和企业主的又一次福音!酷客多小程序新零售o2o商城系统酷爱用户,为了追求极致的用户体验,没日没夜地沉浸于新功能的开发,经过一番努力,新功能终于上线啦! 此次版本迭代,在原有功能基础上做了大幅提升, ...
- 利用SSH端口转发实现跨机器直接访问
在实际项目测试中经常会遇到数据库操作,但是因为公司安全问题,访问数据库往往需要通过跳板机.但通过跳板机,测试效率大打折扣,因此通过使用SSH端口转发,从而达到跨机器直接访问数据库.实际项目中的应用会比 ...
- C#图解教程 第十四章 事件
事件 发布者和订阅者源代码组件概览声明事件订阅事件触发事件标准事件的用法 通过扩展EventArgs来传递数据移除事件处理程序 事件访问器 事件 发布者和订阅者 很多程序都有一个共同的需求,既当一个特 ...
- android小程序之幸运菜谱
android小程序之幸运菜谱 前言:刚刚结束短短5天的android公开课程,收获不少,写下来记录一下吧!(因为学校校企公开课的缘故才偶然接触的android,所以只学了这几天,不喜勿喷) 一开始得 ...
- Log4j各级别日志重复打印
使用filter进行日志过滤 这个其实是Log4j自带的方案,也是推荐方案,不知道为什么网上的资料却很少提到这点.把log4j.properties配置文件修改成如下: #root日志 log4j.r ...
- mongodb在windows下安装启动
mongodb安装 mongodb配置 创建几个文件夹具体如下:数据库路径(\data\db\目录).日志路径(\data\log\目录)和日志文件(mongod.log文件)c:\data\log\ ...