求助,为什么Arithmetic exception
  • 板块灌水区
  • 楼主mixue_bc
  • 当前回复3
  • 已保存回复3
  • 发布时间2024/10/23 17:08
  • 上次更新2024/10/23 19:11:17
查看原帖
求助,为什么Arithmetic exception
1260767
mixue_bc楼主2024/10/23 17:08
#include<bits/stdc++.h>
using namespace std;
const int N=1e6;
struct node{
	string name;
	int fang;
}a[N];
int main(){
	int n;
	cin>>n;
	int m;
	cin>>m;
	for(int i=1;i<=n;i++)cin>>a[i].name>>a[i].fang;
	int now=1;
	for(int i=1;i<=m;i++){
		int q,b,sh;
		cin>>q>>b;
		sh=q*a[now].fang;
		if(sh==0)sh=-1;
		now+=sh*b;
		now=(now+n)%n;
	}
	cout<<a[now].name;
}

样例:

7 3
0 singer
0 reader
0 mengbier 
1 thinker
1 archer
0 writer
1 mogician 
0 3
1 1
0 2
2024/10/23 17:08
加载中...