SGU 175.Encoding

Solution:

简单题。

答案初始化为1.

从给定的n,q往下推出新的n和q,如果q是在右半边,答案加上 n-n/2.

一直到推到n==1。

code:

#include <iostream>
using namespace std;
int n, m;
int main() {
	cin >> n >> m;
	int ans = 1;
	int mid = n / 2;
	while (n > 1) {
              if (m <= mid) ans += n - mid, n = mid, m = mid - m + 1;
              else
                     m = n - m + 1, n -= mid;
		mid = n / 2;
	}
	cout << ans;
	return 0;
}

  

SGU 175.Encoding

时间: 2024-11-06 11:41:12

SGU 175.Encoding的相关文章

The Interpreter and ... 之 Source Code Encoding

在python的源代码文件中,允许使用不同的字符集编码而并非只是ASCII.最好的设置方法是在"#!"之后再多设置一个特殊的行,用来定义源代码文件的编码,就像下面这样: # -*- coding: encoding -*- 通过上诉方式的定义,所有在源代码文件中的字符将都会被看做是(treated  as)指定的编码方式去编码,同时该源文件就允许立即被写入选中的编码的Unicode字符字面量.Python所允许的编码方式,你可以在Python的库参考中找到,在 codecs 这一章节中

“wsimport -keep ”生成客户端报错“Use of SOAP Encoding is not supported.”

本来想用 “wsimport -keep ” 生成客户端,结果报错“Use of SOAP Encoding is not supported.” 应该是缺jar包, 闲麻烦就发现了百度经验上的 这个方法.以下是教程 wsdl文件生成客户端 首先我们需要知道webservice接口地址,这里我的测试地址为http://localhost:8085/Service/Function?wsdl.   右击另存为,保存为.wsdl的文件.   在eclipse中新建一个java项目.   将.wsdl

EBS 11i ojspCompile.pl 编译jsp乱码 encoding

11i环境,一般来说jsp是重启apache后自动编译的,但是因为某些环境设置,需要手动编译jsp. 11i的编译路径:$JTF_TOP/admin/scripts/ojspCompile.pl 编译命令:perl $JTF_TOP/admin/scripts/ojspCompile.pl --compile -p 16 -s xxx.jsp 一个简单的jsp文件test1.jsp,文件编码格式GB2312,代码如下: <%@page language="java" conten

【SGU 390】Tickets (数位DP)

Tickets Description Conductor is quite a boring profession, as all you have to do is just to sell tickets to the passengers. So no wonder that once upon a time in a faraway galaxy one conductor decided to diversify this occupation. Now this conductor

hdu 1020 Encoding

Encoding Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 40214    Accepted Submission(s): 17846 Problem Description Given a string containing only 'A' - 'Z', we could encode it using the followi

ACM: SGU 101 Domino- 欧拉回路-并查集

sgu 101 - Domino Time Limit:250MS     Memory Limit:4096KB     64bit IO Format:%I64d & %I64u Description Dominoes – game played with small, rectangular blocks of wood or other material, each identified by a number of dots, or pips, on its face. The bl

如何设置项目encoding为utf-8

1.鼠标右键点击项目,选择[properties] 2.选择[Resource],在Text file encoding里面选择UTF-8,点击[ok] 大功告成! 木头大哥所发的文章均基于自身实践,各位江湖好汉可以通过:[email protected] 联系之.

svn: Can&amp;#39;t convert string from &amp;#39;UTF-8&amp;#39; to native encoding 解决的方法

今天在down代码时遇到了例如以下问题: [[email protected] ~]$ svn co https://xxxxxxxxxxxxx svn: Can't convert string from 'UTF-8' to native encoding: svn: xxxxxxxx/include/xml_inc/XML/?\194?\184? \194? \180?\194?\188?\195? \190 mcXML.h 这个问题主要是代码中包括了中文名字的文件,svn这边的编码不支持

Non-ASCII character &#39;\xe8&#39; in file xxx.py on line 8, but no encoding declared

使用网上某个python程序,编译时报错: File "xxx.py", line 8         SyntaxError: Non-ASCII character '\xe8' in file xxx.py on line 8, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details 原因是缺少编码类型声明:no encoding declared 段首添加一行声明即可: