📄 pku2591.java
字号:
import java.io.*;
import java.util.*;
public class Main
{
public static void main(String args[]) throws Exception
{
Scanner cin=new Scanner(System.in);
int two,three,i,t1,t2,n;
int s[]=new int[10000000];
two=three=0;
s[0]=1;
for(i=1;i<10000000;i++)
{
t1=2*s[two]+1;
t2=3*s[three]+1;
if(t1<t2)
{
s[i]=t1;
two++;
}
else if(t1>t2)
{
s[i]=t2;
three++;
}
else
{
s[i]=t1;
three++;
two++;
}
}
while(cin.hasNext())
{
n=cin.nextInt();
System.out.println(s[n-1]);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -