当前位置:网站首页>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.
边栏推荐
- Classify boost libraries by function
- JS how to get a list of elements in a collection object
- [ecological partner] Kunpeng system engineer training
- Significance and measures of security encryption of industrial control equipment
- In the past 100 years, only 6 products have been approved, which is the "adjuvant" behind the vaccine competition
- Why must digital transformation strategies include continuous testing?
- 灵动微 MM32 多路ADC-DMA配置
- plantuml介绍与使用
- 三翼鸟两周年:羽翼渐丰,腾飞指日可待
- Pytest collection (2) - pytest operation mode
猜你喜欢

MySQL series transaction log redo log learning notes

名单揭晓 | 2021年度中国杰出知识产权服务团队

【直播回顾】战码先锋首期8节直播完美落幕,下期敬请期待!

91.(cesium篇)cesium火箭发射模拟

Go — 相关依赖对应的exe

In the past 100 years, only 6 products have been approved, which is the "adjuvant" behind the vaccine competition

企业架构与项目管理的关联和区别

高攀不起的希尔排序,直接插入排序

微软、哥伦比亚大学|GODEL:目标导向对话的大规模预训练

mysql 学习笔记-优化之SQL优化
随机推荐
Using closures to switch toggle by clicking a button
Separate the letters and numbers in the string so that the letters come first and the array comes last
Show member variables and methods in classes in idea
The leader of the cloud native theme group of beacon Committee has a long way to go!
Case of camera opening by tour
100年仅6款产品获批,疫苗竞争背后的“佐剂”江湖
Pytest collection (2) - pytest operation mode
Recent public ancestor offline practice (tarjan)
PCB plug hole technology~
月入1W+的自媒体达人都会用到的运营工具
【juc学习之路第9天】屏障衍生工具
Qtreeview+qabstractitemmodel custom model: the third of a series of tutorials [easy to understand]
Is PMP certificate really useful?
Why does blocprovider feel similar to provider?
EasyExcel 复杂数据导出
为什么数字化转型战略必须包括持续测试?
黑马程序员-软件测试--06阶段2-linux和数据库-01-08第一章-linux操作系统阶段内容说明,linux命令基本格式以及常见形式的说明,操作系统的常见的分类,查看命令帮助信息方法,
Manually implement function isinstanceof (child, parent)
Yan Rong looks at how to formulate a multi cloud strategy in the era of hybrid cloud
测试撤销1