UVa 440 - Eeny Meeny Moo

题目:约瑟夫环,有一个环先删掉第一个元素,然后每隔m个数字删掉,问最后剩下的是2号元素,

            则应该去的最小m为多少。

分析:数论,模拟。将元素编号0~n-1,最后剩下编号的递推关系:f(n,m)=(f(n-1,m)+m)%n。

            因此,问题转化成n-1元素,剩下第一个元素的约瑟夫环,按循序枚举m找到第一个成立的即可。

说明:╮(╯▽╰)╭。

#include <iostream>
#include <cstdlib>
#include <cstdio>

using namespace std;

int deal(int n, int m)
{
	int s = 0;
	for (int i = 2; i < n; ++ i)
		s = (s+m)%i;
	return s;
}

int main()
{
	int n;
	while(cin >> n && n) {
		for (int i = 1; ; ++ i) {
			if (!deal(n, i)) {
				cout << i << endl;
				break;
			}
		}
	}
    return 0;
}


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
傻瓜快速了解5g Ixia特别修订版 5g-for-dummies INTRODUCTION................................................................................................ 1 About This Book.................................................................................... 2 Foolish Assumptions............................................................................. 2 Icons Used in This Book........................................................................ 3 Beyond the Book................................................................................... 3 Where to Go from Here........................................................................ 3 CHAPTER 1: Understanding the Journey to a 5G Future............. 5 Tracing the Evolution of Wireless Communications......................... 5 Focusing on the 5G Vision.................................................................... 8 Ordering Up 5G in Five Easy Pieces.................................................... 9 CHAPTER 2: Achieving Faster Speeds and Larger Feeds...........11 Fattening the Data Pipe......................................................................11 We All Bundle — with CA....................................................................13 Eeny, Meeny, Miny, MIMO..................................................................14 No Qualms About QAM......................................................................15 CHAPTER 3: Tapping into Unlicensed Spectrum..............................17 Giving a “High 5(G)” to Wi-Fi Advancements....................................17 LTE in Unlicensed Spectrum..............................................................18 License Assisted Access......................................................................19 MulteFire..............................................................................................20 CHAPTER 4: Enabling Massive IoT................................................................21 Key Connectivity Requirements for IoT Devices..............................21 NarrowBand IoT (NB-IoT)...................................................................22 Long Term Evolution for Machines (LTE-M).....................................23 LoRaWAN and Sigfox..........................................................................23 CHAPTER 5: Getting Real About the Need to Virtualize............25 Driving 5G and IoT with Virtualization..............................................25 Recognizing the IoT explosion......................................................26 Focusing on service.......................................................................26 Managing the migration................................................................

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值