题解 | #扭蛋机#
扭蛋机
https://www.nowcoder.com/practice/9d26441a396242a9a0f7d2106fc130c7?tpId=182&tqId=34599&rp=1&ru=/exam/intelligent&qru=/exam/intelligent&sourceUrl=%2Fexam%2Fintelligent%3FquestionJobId%3D10%26tagId%3D21004&difficulty=undefined&judgeStatus=undefined&tags=&title=
using System; using System.Linq; using System.Collections.Generic; public class Program { public static void Main() { string line; int a = 0; string c = ""; while ((line = System.Console.ReadLine()) != null&&line!="") { // 注意 while 处理多个 case a = Convert.ToInt32(line); } while (a != 1 && a != 0) { if (a % 2 == 0) { c += "3"; a = (a - 2) / 2; } if (a % 2 == 1) { c += "2"; a = (a - 1) / 2; } } if(a==1) { c += "2"; } c = String.Join("", c.Reverse()); Console.WriteLine(c); } }