当前位置:网站首页>Yyds dry goods inventory # solve the real problem of famous enterprises: egg twisting machine
Yyds dry goods inventory # solve the real problem of famous enterprises: egg twisting machine
2022-07-01 22:31:00 【51CTO】
1. sketch :
describe
22 Niang he 33 My mother received the task of twisting eggs from the little TV gentleman :
There are two egg twisting machines , The numbers are egg twisting machine 2 And the egg twisting machine 3 Number ,22 Mother uses an egg twisting machine 2 Number ,33 Mother uses an egg twisting machine 3 Number .
No coin is needed for the egg twisting machine , But there is a special ability :
Twisted egg machine, 2 Number : If you plug x(x The scope is >=0 Integers ) Twist an egg in , Then you can twist to 2x+1 individual
Twisted egg machine, 3 Number : If you plug x(x The scope is >=0 Integers ) Twist an egg in , Then you can twist to 2x+2 individual
22 Niang he 33 Mother didn't twist the egg in her hand , I need you to help them design a plan , Two person “ Twist in turn ”( Whoever starts first is unlimited , The twisted egg can be used by the other party ), use “ least ” The number of times , So that they can finally twist to N Give one to the little TV gentleman .
Input description :
Enter a positive integer , What you need for a small TV N A twisted egg .
Output description :
Output a string , Each character represents the egg twisting machine , Characters can only contain "2" and "3".
Example 1
Input :
Output :
2. Code implementation :
import java.util.*;
import java.io.*;
public class Main{
public static void main(String[] args){
Scanner cin = new Scanner(new BufferedInputStream(System.in));
int n = cin.nextInt();
StringBuilder ans = new StringBuilder();
while(n!=0){
if((n&1)==1){
n=(n-1)/2;
ans.append('2');
}else{
n=(n-2)/2;
ans.append('3');
}
}
System.out.println(ans.reverse());
}
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
边栏推荐
- Four methods of JS array splicing [easy to understand]
- Introduction and download of the latest version of airserver2022
- 91.(cesium篇)cesium火箭发射模拟
- Redis配置与优化
- Sonic云真机学习总结6 - 1.4.1服务端、agent端部署
- EasyExcel 复杂数据导出
- Which securities company should we choose to open an account for flush stock? Is it safe to open an account with a mobile phone?
- Flume interview questions
- PCB plug hole technology~
- 月入1W+的自媒体达人都会用到的运营工具
猜你喜欢
随机推荐
91.(cesium篇)cesium火箭发射模拟
#yyds干货盘点# 解决名企真题:扭蛋机
leetcode - 287. 寻找重复数
对象内存布局
[live broadcast review] the first 8 live broadcasts of battle code Pioneer have come to a perfect end. Please look forward to the next one!
Unity 使用Sqlite
使用闭包实现点击按钮切换 toggle
Business visualization - make your flowchart'run'up
AirServer2022最新版功能介绍及下载
PCB plug hole technology~
An operation tool used by we media professionals who earn 1w+ a month
完全注解的ssm框架搭建
LIS (longest ascending subsequence) problem that can be understood [easy to understand]
In the past 100 years, only 6 products have been approved, which is the "adjuvant" behind the vaccine competition
Icml2022 | interventional contrastive learning based on meta semantic regularization
Tops, the unit of computing power of the processor, can be carried out 1 trillion times per second
Use of vscode
The difference between NiO and traditional IO
名单揭晓 | 2021年度中国杰出知识产权服务团队
GaussDB(DWS)主动预防排查