テンセントの微信のお年玉のアルゴリズム

1877 ワード


const-string v0, "this is a test"  
  
    const/16 v1, 0x3e8  
  
    invoke-static {p0, v0, v1}, Landroid/widget/Toast;->makeText(Landroid/content/Context;Ljava/lang/CharSequence;I)Landroid/widget/Toast;  
  
    move-result-object v0  
  
    invoke-virtual {v0}, Landroid/widget/Toast;->show()V

const-stringv0,"HelloWorld.SmaliHere"const/4v1,0x1 invoke-static{p0,v0,v1},\ Landroid/widget/Toast;->makeText(Landroid/content/Context;Ljava/lang/CharSequence;I)Landroid/widget/Toast; move-result-objectv0 invoke-virtual{v0},Landroid/widget/Toast;->show()V


public static void main(String[] args) {

                double money; //      
                int people; //       
                double min_money;
                //              0 

                money = 10;
                people = 4;
                min_money = 0.01;

                for (int i = 0; i < people - 1; i++) {
                        int k = i + 1;
                        double safe_money = (money - (people - k) * min_money)
                                        / (people - k);
                        double tmp_money = (Math.random()
                                        * (safe_money * 100 - min_money * 100) + min_money * 100) / 100;
                        money = money - tmp_money;
                        System.out.format("  %d    : %.2f  ,  : %.2f  
", k, tmp_money, money); } System.out.format(" %d : %.2f , : 0
", people, money); }