掘金小铺出了这么多可以兑换的礼品,弄的人心里痒痒,有不想参加活动的大兄带要花多少时间可以兑换呢? 首先搞个方法简单算一下天数
public int calcdays(int total) {
int [] listdiamond = {100,150,512,250,300,350,1024,450,500,550,600,650,700,
2048,700,700,700,700,700,700,4096,700,700,700,700,700,700,700,700,5120};
int diamondtotal30 = 0;
for (int i = 0; i < listdiamond.length; i++) {
diamondtotal30 += listdiamond[i];
}
int ds30 = total / diamondtotal30; //30天的总数
int ds = total % diamondtotal30; //多的矿石数
int sum = 0;
int lday = 0;
for (int i = 0; i < listdiamond.length; i++) {
if(sum < ds) {
sum += listdiamond[i];
lday = i+1;
}else
break;
}
int totaldays = ds30*30 + lday;
return totaldays;
}
得到天数之后,再简单计算一下从今天开始不断签那一天可以兑换
public void calcdate(int days) {
Date d = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String date = format.format(d);
System.out.println("现在的日期是:" + date);
Calendar ca = Calendar.getInstance();
ca.add(Calendar.DATE, days);
d = ca.getTime();
String backTime = format.format(d);
System.out.println("增加天数以后的日期:" + backTime);
}
算了一下任天堂NS(490w):
现在的日期是:2021-11-12 增加天数以后的日期:2036-01-04
大概也就14年多吧。
大家想通过签到兑换大奖的加油(xixishui)。
总结:
想兑大奖还得常常关注掘金活动,多多撸活动才是正经的
2021年11月29日更新
由于获取矿石渠道变更,可以通过游戏获取(周一到周五1500,周末3000),那么签到+游戏拉满需要多久呢?
原来的代码已经不能满足需求了,需要修改一下calcdays函数
public static int calcdays(int total) {
List<Integer> listDiamond = Arrays.asList(100,150,512,250,300,350,1024,450,500,550,600,650,700,
2048,700,700,700,700,700,700,4096,700,700,700,700,700,700,700,700,5120);
List<Integer>listGameDiamond =Arrays.asList(3000,1500,1500,1500,1500,1500,3000);
int weekDay_today = getWeekday();
List<Integer> gameDiamond = moveListLeft(listGameDiamond, weekDay_today-1);
int totalDiamond = 0;
int totalday = 0;
while(totalDiamond < total) {
totalDiamond += listDiamond.get(totalday%30).intValue();
totalDiamond += gameDiamond.get(totalday%7).intValue();
totalday += 1;
}
System.out.println("总共需要"+totalday+"天");
return totalday;
}
//获取当日是周几
private static int getWeekday() {
Date today = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(today);
return cal.get(Calendar.DAY_OF_WEEK);
}
//列表左移动
private static List<Integer> moveListLeft(List<Integer> listDiamond, int p) {
List<Integer> list = new ArrayList<>();
for(int i = p ; i < listDiamond.size();i++) {
list.add(listDiamond.get(i));
}
for(int i = 0; i < p;i++) {
list.add(listDiamond.get(i));
}
return list;
}
这样又可以算出新的日期啦,再算任天堂NS(490w):
总共需要1731天 现在的日期是:2021-11-29 增加天数以后的日期:2026-08-26
差不多比原来减少了70%的时间
2022年1月25日更新
问题来了,我已经签到了一些日子,我还有多少天才能兑大奖呢?
在原来代码的基础上只需要修改计算日期的方法,加参数已有矿石、连续签到天数,今天是否签到,然后做简单处理,具体如下:
/**
*
* @param total 总共需要的矿石
* @param ihad 已有的矿石
* @param checkIndays 已连续签到多少天
* @param ischkInToday 今天是否已签到
* @return
*/
public static int calcdays(int total, int ihad, int checkIndays, boolean ischkInToday) {
List<Integer> listDiamond = Arrays.asList(100,150,512,250,300,350,1024,450,500,550,600,650,700,
2048,700,700,700,700,700,700,4096,700,700,700,700,700,700,700,700,5120);
List<Integer>listGameDiamond =Arrays.asList(3000,1500,1500,1500,1500,1500,3000);
int weekDay_today = getWeekday();
List<Integer> gameDiamond = new ArrayList<>();
if (ischkInToday) {
gameDiamond = moveListLeft(listGameDiamond, weekDay_today);
checkIndays = checkIndays+1;
}else {
gameDiamond = moveListLeft(listGameDiamond, weekDay_today-1);
}
int totalDiamond = 0;
int totalday = 0;
int moreDiamoind = total - ihad;
while(totalDiamond < moreDiamoind) {
totalDiamond += listDiamond.get((totalday+checkIndays)%30).intValue();
totalDiamond += gameDiamond.get(totalday%7).intValue();
totalday += 1;
}
if(!ischkInToday)
totalday -= 1;
System.out.println("总共还需要"+totalday+"天");
return totalday;
}
例如我现在今天有5w矿石,今天签到了(连续签到100天了),我想要任天堂(490w)还需要至多签到多少天呢?
总共还需要1712天 现在的日期是:2022-01-25 增加天数以后的日期:2026-10-03
2022年2月23日更新
来坏消息了,今天规则有变化,每日海底掘金数量减半。只需要listGameDiamond数组变化。 ListlistGameDiamond =Arrays.asList(1500,750,750,750,750,750,1500);
再来算一遍
例如我现在今天有5w矿石,今天签到了(连续签到100天了),我想要任天堂(490w)还需要至多签到多少天呢?
总共还需要2592天 现在的期是:2022-02-23 增加天数以后的日期:2029-03-30
比原来多了两年半 T_T
2022年2月24日更新
掘金又有新的“数字谜题”的游戏,一周挑战满30关可获得2500矿石(海底掘金的坑还是填不上啊)。
更新计算方法,在每周开始的第一天就假设拉满,这样一周就有5200矿石(200+1000+1500+2500),可以获得如下的代码
/**
*
* @param total 总共需要的矿石
* @param ihad 已有的矿石
* @param checkIndays 已连续签到多少天
* @param ischkInToday 今天是否已签到
* @return
*/
public static int calcdays(int total, int ihad, int checkIndays, boolean ischkInToday) {
List<Integer> listDiamond = Arrays.asList(100,150,512,250,300,350,1024,450,500,550,600,650,700,
2048,700,700,700,700,700,700,4096,700,700,700,700,700,700,700,700,5120);
// List<Integer>listGameDiamond =Arrays.asList(3000,1500,1500,1500,1500,1500,3000);
List<Integer>listGameDiamond =Arrays.asList(1500,750,750,750,750,750,1500);
int weekDay_today = getWeekday();
List<Integer> gameDiamond = new ArrayList<>();
if (ischkInToday) {
gameDiamond = moveListLeft(listGameDiamond, weekDay_today);
checkIndays += 1;
}else {
gameDiamond = moveListLeft(listGameDiamond, weekDay_today-1);
}
int totalDiamond = 0;
int totalday = 0;
int moreDiamoind = total - ihad;
while(totalDiamond < moreDiamoind) {
totalDiamond += listDiamond.get((totalday+checkIndays)%30).intValue();
totalDiamond += gameDiamond.get(totalday%7).intValue();
if(totalday%7 == 1)
totalDiamond += 5200;
totalday += 1;
}
if(!ischkInToday)
totalday -= 1;
System.out.println(totalDiamond);
System.out.println("总共还需要"+totalday+"天");
return totalday;
}
还是那个条件,例如我现在今天有5w矿石,今天签到了(连续签到100天了),我想要任天堂(490w)还需要至多签到多少天呢?
总共还需要1855天 现在的日期是:2022-02-24 增加天数以后的日期:2027-03-25
好嘛,比单纯玩海底掘金+签到少了737天。但是有问题来了,这个数字谜语难度系数比海底高,需要的时间成本会大大增加。
2022年4月11日更新
为了使情况更加接近实际,新增每日抽奖随机矿石(据我几个月观察基本在0-130之间):
/**
*
* @param total 总共需要的钻石
* @param ihad 已有的钻石
* @param checkIndays 已连续签到多少天
* @param ischkInToday 今天是否已签到
* @return
*/
public static int calcdays(int total, int ihad, int checkIndays, boolean ischkInToday) {
List<Integer> listDiamond = Arrays.asList(100,150,512,250,300,350,1024,450,500,550,600,650,700,
2048,700,700,700,700,700,700,4096,700,700,700,700,700,700,700,700,5120);
// List<Integer>listGameDiamond =Arrays.asList(3000,1500,1500,1500,1500,1500,3000);
List<Integer>listGameDiamond =Arrays.asList(1500,750,750,750,750,750,1500);
int weekDay_today = getWeekday();
List<Integer> gameDiamond = new ArrayList<>();
if (ischkInToday) {
gameDiamond = moveListLeft(listGameDiamond, weekDay_today);
checkIndays += 1;
}else {
gameDiamond = moveListLeft(listGameDiamond, weekDay_today-1);
}
int totalDiamond = 0;
int totalday = 0;
int moreDiamoind = total - ihad;
while(totalDiamond < moreDiamoind) {
totalDiamond += listDiamond.get((totalday+checkIndays)%30).intValue();
totalDiamond += gameDiamond.get(totalday%7).intValue();
totalDiamond += new Random().nextInt(130); //每日抽奖随机矿石
if(totalday%7 == 1)
totalDiamond += 5200;
totalday += 1;
}
if(!ischkInToday)
totalday -= 1;
System.out.println(totalDiamond);
System.out.println("总共还需要"+totalday+"天");
return totalday;
}
再来算一遍
例如我现在今天有5w矿石,今天签到了(连续签到100天了),我想要任天堂(490w)还需要至多签到多少天呢?
总共还需要1810天 现在的日期是:2022-04-11 增加天数以后的日期:2027-03-26
2022年4月13日更新
掘金已出几次瓜分矿石的活动,为了让计算结果与实际结果更加接近决定将其计算进来。10w个bug瓜分700w个矿石,平均每个bug值70个矿石。然后又有一个规则如下
也就是说我们积攒bug到达1000再出手,或者出一次活动出手一次。 获取bug的途径有抽奖(假设我们只做每日的免费抽奖)和收集(工作日最多一天4个,周末一天6个)。
那么代码需
/**
*
* @param total 总共需要的钻石
* @param ihad 已有的钻石
* @param checkIndays 已连续签到多少天
* @param ischkInToday 今天是否已签到
* @param ischkInToday 是否利益最大化
* @return
*/
public static int calcdays(int total, int ihad, int checkIndays, boolean ischkInToday,boolean isMax) {
List<Integer> listDiamond = Arrays.asList(100,150,512,250,300,350,1024,450,500,550,600,650,700,
2048,700,700,700,700,700,700,4096,700,700,700,700,700,700,700,700,5120);
List<Integer>listGameDiamond =Arrays.asList(1500,750,750,750,750,750,1500);
List<Integer>listBug =Arrays.asList(6,4,4,4,4,4,6); //网页和app均收集bug
int weekDay_today = getWeekday();
List<Integer> gameDiamond = new ArrayList<>();
if (ischkInToday) {
gameDiamond = moveListLeft(listGameDiamond, weekDay_today);
listBug = moveListLeft(listBug, weekDay_today);
checkIndays += 1;
}else {
gameDiamond = moveListLeft(listGameDiamond, weekDay_today-1);
listBug = moveListLeft(listBug, weekDay_today-1);
}
int totalDiamond = 0;
int totalday = 0;
int moreDiamoind = total - ihad;
while(totalDiamond < moreDiamoind) {
totalDiamond += listDiamond.get((totalday+checkIndays)%30).intValue();
totalDiamond += gameDiamond.get(totalday%7).intValue();
int dailyDiamond = new Random().nextInt(130); //随机为0则是抽中bug
totalDiamond += dailyDiamond; //每日抽奖随机矿石
if(isMax)//利益最大化,等到1000之后兑换bug是1.5倍
totalDiamond += (dailyDiamond==0)?((listBug.get(totalday%7).intValue()+1)*70*1.5):(listBug.get(totalday%7).intValue()*70*1.5);
else//利益普通化,等到100之后兑换bug是1倍
totalDiamond += (dailyDiamond==0)?((listBug.get(totalday%7).intValue()+1)*70):(listBug.get(totalday%7).intValue()*70);
if(totalday%7 == 1)
totalDiamond += 5200;
totalday += 1;
}
if(!ischkInToday)
totalday -= 1;
System.out.println(totalDiamond);
System.out.println("总共还需要"+totalday+"天");
return totalday;
}
例如我现在今天有5w矿石,今天签到了(连续签到100天了),我想要任天堂(490w)还需要至多签到多少天呢?
普通瓜分矿石:
总共还需要1616天 现在的日期是:2022-04-13 增加天数以后的日期:2026-09-15
利益最大化瓜分矿石:
总共还需要1535天 现在的日期是:2022-04-13 增加天数以后的日期:2026-06-26
好家伙这一下子又少了半年,利益最大化则又少了9个月左右。
2022年7月19日更新
最近每周四都有神转折的故事会活动,奖励是1000矿石 那么修改一下代码变成 if(totalday%7 == 1) totalDiamond += 6200; //5200(数字谜题)+1000(周四神转折)
再来算一下: 例如我现在今天有5w矿石,今天签到了(连续签到100天了),我想要任天堂(490w)还需要至多签到多少天呢?
普通瓜分矿石:
总共还需要1543天 现在的日期是:2022-07-19 增加天数以后的日期:2026-10-09
利益最大化瓜分矿石:
总共还需要1468天 现在的日期是:2022-07-19 增加天数以后的日期:2026-07-26
又离switch到手少了一个月,加油!!!
2022年7月19日更新
最近发现获取bug的数量有变化(原来规则见上文)
修改代码
List<Integer>listBug =Arrays.asList(8,4,4,4,4,4,8); //网页和app均收集bug
周末由原来6个变成8个,再来计算
例如我现在今天有5w矿石,今天签到了(连续签到100天了),我想要任天堂(490w)还需要至多签到多少天呢?
普通瓜分矿石:
总共还需要1523天 现在的日期是:2022-07-28 增加天数以后的日期:2026-09-28
利益最大化瓜分矿石:
总共还需要1442天 现在的日期是:2022-07-28 增加天数以后的日期:2026-07-09
又少了半个月
xdm期待新的矿石任务吧!!!