队列写法,90%通过率,求优化

#include <bits/stdc++.h>

using namespace std;

queue<int> a;

void solve()

{

int n , k , m , x;

cin >> n >> k >> m;

for(int i = 1 ; i <= n ; i++) a.push(i);

for(int i = 1 ; i < k ; i++){

x = a.front();

a.push(x);

a.pop();

}

while(a.size() != 1){

for(int i = 1 ; i < m ; i++)

{

x = a.front();

a.push(x);

a.pop();

}

a.pop();

}

cout << a.front();

}

int main()

{

ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

int t = 1;

//cin >> t;

while(t--)

{

solve();

}

return 0;

}

全部评论

相关推荐

06-18 08:36
湖南大学 Java
运营你豪哥:没啥拷打的 1.增加量化结果,现在有点缺效果数据 2.突出复杂性,现在的项目描述有点像功能清单,强调一下技术难点和解决方案。
不给转正的实习,你还去吗
点赞 评论 收藏
分享
05-30 12:03
山西大学 C++
offer来了我跪着...:不是骗子,等到测评那一步就知道为啥这么高工资了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务