加急求解Expected BEGIN_ARRAY but was STRING 20C

加急求解:Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $

![图片说明](https://img-ask.csdn.net/upload/201808/13/1534137196_670067.png)图片说明图片说明

以上是错误和目录

我在网上也百度了不少,但都说是jons 的问题,鄙人也是刚刚入门安卓的菜鸟一只,还请各路大神救救我,帮我看看是什么问题

代码两三页,这里贴着不方便
+QQ948677543

小弟在此谢过!谢过! 谢过!


2个回答

不用你用system。out将json字符串类容打印发出来就可以了

:Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $
文件不对,应该是string,但是你给的是数组

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Expected BEGIN_OBJECT but was STRING
Expected BEGIN_OBJECT but was STRING at line 1 column 1 path 我要往阿里云上传照片,一点上传就出现这个问题 ![图片说明](https://img-ask.csdn.net/upload/201610/09/1476023998_566077.png) 错误的地方:![图片说明](https://img-ask.csdn.net/upload/201610/09/1476024051_581763.png)
Expected a BEGIN_ARRAY but was STRING at line
android访问本机后台没问题。能够返回正常的数据,但是我把本机后台项目打包成war包放在 服务器上,然后用android去访问服务器,就会报如下错误: ``` Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $ at com.google.gson.Gson.fromJson(Gson.java:899) at com.google.gson.Gson.fromJson(Gson.java:852) at com.google.gson.Gson.fromJson(Gson.java:801) at com.example.ldp.com.activity.StudentActivity.initFruits(StudentActivity.java:107) at com.example.ldp.com.activity.StudentActivity.onCreate(StudentActivity.java:51) at android.app.Activity.performCreate(Activity.java:5231) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104) ``` 访问代码: ``` private void initFruits(){ Map<String,String> map = new HashMap<>(); map.put("username",username); String str = HttpGetUtil.SendPostHttp("showcourse/toshowcourse.action",map); Log.i("LDP",str); Gson gson = new Gson(); coursesList = gson.fromJson(str,new TypeToken<List<Course>>(){}.getType()); if(coursesList.size()==0){ Toast.makeText(StudentActivity.this,"cuowu",Toast.LENGTH_SHORT).show(); } } ``` 后台返回的json数据格式: ![图片说明](https://img-ask.csdn.net/upload/201705/08/1494226654_710863.png)
Gson : Expected BEGIN_ARRAY but was BEGIN_OBJECT
使用Gson解析的时候,遇到这个问题: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 21 path $.data Json字符串是这样的: { "data": { "banner": [ { "aid": "7", "catid": "0", "description": "asd", "end_time": "1432915200", "imgurl": "/upload/ads/2015-05-06/5549ac6f05399.jpg", "is_open": "1", "link": "http://", "order": "50", "start_time": "1430755200", "title": "asd" } ], "cat": [ { "addtime": "1429063456", "arrchildid": "1", "arrparentid": "", "catid": "1", "catname": "母婴2", "child": "0", "image": "", "is_show": "1", "listorder": "123", "pid": "0", "style": "0" }, { "addtime": "1429063835", "arrchildid": "2,3,4,12,16", "arrparentid": "", "catid": "2", "catname": "第三方", "child": "0", "image": "", "is_show": "1", "listorder": "0", "pid": "0", "style": "0" }, { "addtime": "1429068195", "arrchildid": "6,14", "arrparentid": "", "catid": "6", "catname": "母婴1", "child": "0", "image": "", "is_show": "1", "listorder": "0", "pid": "0", "style": "0" }, { "addtime": "1429068572", "arrchildid": "7", "arrparentid": "", "catid": "7", "catname": "母婴", "child": "0", "image": "", "is_show": "1", "listorder": "0", "pid": "0", "style": "0" }, { "addtime": "1429068577", "arrchildid": "8", "arrparentid": "", "catid": "8", "catname": "母婴水电费", "child": "0", "image": "", "is_show": "1", "listorder": "0", "pid": "0", "style": "0" }, { "addtime": "1429153032", "arrchildid": "11,13", "arrparentid": "", "catid": "11", "catname": "水电费水电费", "child": "0", "image": "", "is_show": "1", "listorder": "0", "pid": "0", "style": "0" }, { "addtime": "1430117866", "arrchildid": "15", "arrparentid": "", "catid": "15", "catname": "SDFG", "child": "0", "image": "", "is_show": "1", "listorder": "0", "pid": "0", "style": "0" } ], "filter": { "catid": 0, "keywords": "" }, "goods": [ { "addtime": "123123123", "brokerage": "600.00", "catid": "2", "collection": "0", "content": "", "description": "", "id": "4", "images": "", "is_delete": "0", "is_recommend": "1", "is_sale": "1", "keywords": "", "listorder": "12", "market_price": "1500.00", "on_sale": "0", "price": "1200.00", "sales": "0", "spec_array": "", "status": "1", "store": "120", "title": "我是商品1", "userid": "2" } ] }, "status": 0 } 使用HiJson格式化是这样的: ![图片说明](https://img-ask.csdn.net/upload/201505/07/1430994254_213752.png) 我的MallBean.java是这样写的 ``` public class MallBean { public List<MallData> data; public int status; public class MallData{ public List<MallDataBanner> banner; public List<MallDataCat> cat; public MallDataFilter filter; public List<MallDataGoods> goods; } public class MallDataBanner{ public String aid; public String catid; public String description; public String end_time; public String imgurl; public String is_open; public String link; public String order; public String start_time; public String title; } public class MallDataCat{ public String addtime; public String arrchildid; public String arrparentid; public String catid; public String catname; public String child; public String image; public String is_show; public String listorder; public String pid; public String style; } public class MallDataFilter{ public int catid; public String keywords; } public class MallDataGoods{ public String addtime; public String brokerage; public String catid; public String collection; public String content; public String description; public String id; public String images; public String is_delete; public String is_recommend; public String is_sale; public String keywords; public String listorder; public String market_price; public String on_sale; public String price; public String sales; public String status; public String store; public String title; public String userid; } } ``` 我解析是这样的(一下三种方法都是报同样的错): ``` Gson gson = new Gson(); MallBean mallBeanGson = gson.fromJson(response, MallBean.class); // MallBean mallBeanGson = gson.fromJson(response, new TypeToken<MallBean>(){}.getType()); // List<MallBean> mallBeanGson = gson.fromJson(response, new TypeToken<List<MallBean>>(){}.getType()); ```
代码出现 java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 21
这行代码是ResponseObject<List<Goods>> object=new GsonBuilder().create().fromJson(arg0.result, new TypeToken<ResponseObject<List<Goods>>>(){}.getType()); 求问什么原因有什么办法处理吗
:Expected BEGIN_ARRAY求大神们
12-03 01:40:58.903 3439-3456/? E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher Process: com.h954gmail.y.cnch, PID: 3439 com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $ at com.google.gson.Gson.fromJson(Gson.java:899) at com.google.gson.Gson.fromJson(Gson.java:852) at com.google.gson.Gson.fromJson(Gson.java:801) at com.h954gmail.y.cnch.fragment.HomeFragment$1.onResponse(HomeFragment.java:88) at okhttp3.RealCall$AsyncCall.execute(RealCall.java:126) at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818) Caused by: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $ at com.google.gson.stream.JsonReader.beginArray(JsonReader.java:350) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:80) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61) at com.google.gson.Gson.fromJson(Gson.java:887) at com.google.gson.Gson.fromJson(Gson.java:852)  at com.google.gson.Gson.fromJson(Gson.java:801)  at com.h954gmail.y.cnch.fragment.HomeFragment$1.onResponse(HomeFragment.java:88)  at okhttp3.RealCall$AsyncCall.execute(RealCall.java:126)  at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)  at java.lang.Thread.run(Thread.java:818)  求解!!
IllegalStateException
IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2
Android 里retrofit解析报错
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $
怎么把百度返回的Gson格式信息转换成集合?
renderReverse&&renderReverse({"status":0,"result":{"location":{"lng":116.322987,"lat":39.983424071404},"formatted_address":"北京市海淀区中关村大街27号1101-08室","business":"人民大学,中关村,苏州街","addressComponent":{"city":"北京市","district":"海淀区","province":"北京市","street":"中关村大街","street_number":"27号1101-08室"},"cityCode":131}}) 怎么解析成集合? Gson gso=new Gson(); List xinxi=gso.fromJson(line, List.class); 我Java这样写但是报错 错误信息是: Expected BEGIN_ARRAY but was STRING at line 1 column 1
Gson解析Json数据出现了异常
在用Gson解析如下Json的时候 String jsonStr = "{code:403,msg:无查询好友信息,result:[]}"; 解析代码为: Gson son = new Gson(); MessageInfo info = son.fromJson(jsonStr, MessageInfo.class); System.out.println(info.getCode()); System.out.println(info.getResult()); System.out.println(info.getMsg()); MessageInfo.java private int code; private String msg; private Result result; result为空的时候,就会出现异常 com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 31 望大神帮下忙,解决下,这个怎么来解析
gson将json格式的字符串转成java对象,json字符串中long怎么转变不会报错?
# gson将json格式的字符串转成java对象,json字符串中long怎么转变不会报错? public static void main(String[] args) { long timel=12323232L; SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String time=sdf.format(timel); System.out.println(time);//正常 Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create(); String obj="[{\"name\":\"caochuankui\",\"time\":"+timel+"}]"; JSONArray objo=new JSONArray(obj); GsonTest gt=gson.fromJson(objo.toString(), GsonTest.class);//报错 System.out.println(gt.getTime()); } } 错误信息如下: 1970-01-01 11:25:23 Exception in thread "main" com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $ at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:200) at com.google.gson.Gson.fromJson(Gson.java:810) at com.google.gson.Gson.fromJson(Gson.java:775) at com.google.gson.Gson.fromJson(Gson.java:724) at com.google.gson.Gson.fromJson(Gson.java:696) at com.pagecofig.util.GsonTest.main(GsonTest.java:67) Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $ at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:387) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:189) ... 5 more 这要怎么解决,求大神指点
Android 的Gson解析问题
public class DataEntity { /** * search_array : ["测试","解决"] * hot_search : ["解决","测试","12","测试3","黄金"] * major_search : ["专业搜索","专业搜索","专业搜索","专业搜索","专业搜索","专业搜索","专业搜索","专业搜索","专业搜索"] */ private List<Search_arrayEntity> search_array; private List<Hot_searchEntity> hot_search; private List<Major_searchEntity> major_search; public void setSearch_array(List<Search_arrayEntity> search_array) { this.search_array = search_array; } public void setHot_search(List<Hot_searchEntity> hot_search) { this.hot_search = hot_search; } public void setMajor_search(List<Major_searchEntity> major_search) { this.major_search = major_search; } public List<Search_arrayEntity> getSearch_array() { return search_array; } public List<Hot_searchEntity> getHot_search() { return hot_search; } public List<Major_searchEntity> getMajor_search() { return major_search; } public class Hot_searchEntity{ public String getTdata() { return tdata; } public void setTdata(String tdata) { this.tdata = tdata; } private String tdata; } public class Search_arrayEntity{ public String getData() { return data; } public void setData(String data) { this.data = data; } private String data; } public class Major_searchEntity{ public String data1; public String getDatat() { return data1; } public void setDatat(String data1) { this.data1 = data1; } } } 这样写实体类对吗? JsonException.JSON_TYPE json_type=JsonException.getJSONType(jsonObject.optString("data")); if(json_type.equals(JsonException.JSON_TYPE.JSON_TYPE_ARRAY)){ SearchBean searchBean=new Gson().fromJson(s, new TypeToken<SearchBean>(){}.getType()); searchView.getSuccess(searchBean); Log.e("GGG","arry"); }else if(json_type.equals(JsonException.JSON_TYPE.JSON_TYPE_OBJECT)){ SearchBean searchBean=new Gson().fromJson(s,SearchBean.class); searchView.getSuccess(searchBean); 报错信息如下: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 38 path $.data.search_array[0]
json解析json解析json解析
解析json出错 Expected BEGIN_ARRAY but was STRING at line 1 column 861 不知道怎么解析 这是返回的json: [{"Id":4,"ProductCode":"W003","ProductName":"智能钱包1号","ProductSName":"智能钱包1号","Description":"沿海银行推出的人民币理财系列产品,主要投资于优质信托融资项目、银行间债券市场的高信用等级债券等金融工具、理财计划、银行存款、承兑汇票等金融产品。期限灵活多选,并通过多种有效投资组合保障投资者的收益稳定可靠","Days":0,"TotalRaisedAmount":0.000000,"HasRaisedAmount":0.000000,"RaisedPercent":0.0,"RaisingStartDate":null,"RaisingEndDate":null,"ActualEstablishDate":null,"ProudctValueDate":null,"ProductDueDate":null,"EstimateCreditableDate":null,"ProductTypeId":2,"ProductTypeName":"IntelligentWallet","GoldExchangeName":"天安金交所","BankName":"沿海银行","BaseAmount":1.000000,"AdditionalAmount":1.000000,"PersonMaxAmount":0.000000,"Remark":null,"TDays":1,"TDaysForRedemption":1,"NearlySevenRate":4.320000,"MaxNearlySevenRate":0.000000,"MinNearlySevenRate":0.000000,"AmountPerMillion":1.150000,"IsNewComerBuy":true,"IsLimitTimeBuy":false,"StartDate":null,"EndDate":null,_"ProfitRule"_:"[{"Lv": 0,"Period": 7,"AmountPerMillion":1.15,"Rate": 4.51},{"Lv": 1,"Period": 15,"AmountPerMillion":1.16,"Rate": 4.52},{"Lv": 2,"Period": 30,"AmountPerMillion":1.17,"Rate": 4.53},{"Lv": 3,"Period": 45,"AmountPerMillion":1.18,"Rate": 4.54},{"Lv": 4,"Period": 60,"AmountPerMillion":1.19,"Rate": 4.55},{"Lv": 5,"Period": 75,"AmountPerMillion":1.20,"Rate": 4.56},{"Lv": 6,"Period": 90,"AmountPerMillion":1.21,"Rate": 4.57},{"Lv": 7,"Period": 120,"AmountPerMillion":1.22,"Rate": 4.58}]","HtmlBuyRule":null,"HtmlRedemptionRule":null,"HtmlProfitRule":null,"HtmlAssetRule":null} 这个是我的bean类: private int Id; private String ProductCode; private String ProductName; private String ProductSName; private String Description; private int Days; private double TotalRaisedAmount; private double HasRaisedAmount; private double RaisedPercent; private Object RaisingStartDate; private Object RaisingEndDate; private Object ActualEstablishDate; private Object ProudctValueDate; private Object ProductDueDate; private Object EstimateCreditableDate; private int ProductTypeId; private String ProductTypeName; private String GoldExchangeName; private String BankName; private double BaseAmount; private double AdditionalAmount; private double PersonMaxAmount; private Object Remark; private int TDays; private int TDaysForRedemption; private double NearlySevenRate; private double MaxNearlySevenRate; private double MinNearlySevenRate; private double AmountPerMillion; private boolean IsNewComerBuy; private boolean IsLimitTimeBuy; private Object StartDate; private Object EndDate; private List<Object> ProfitRule; private Object HtmlBuyRule; private Object HtmlRedemptionRule; private Object HtmlProfitRule; private Object HtmlAssetRule; 然后错误是出在这一行: dqlcproductEntityList = gson.fromJson(string, new TypeToken<List<ZnqbEntity>>(){}.getType()); 有没有大神知道怎么回事 是不是bean不对 主要看那个ProfitRule错误是Expected BEGIN_ARRAY but was STRING at line 1 column 861
pytorch expected Tensor as element 0 in argument 0, but got tuple
做风格迁移学习时,在 target_feature=model(style_img).clone()发生错误,expected Tensor as element 0 in argument 0, but got tuple 然而style_img的格式是torch.cuda.FloatTensor import torch import torch.nn as nn from torch.autograd import Variable import torch.optim as optim from PIL import Image import matplotlib.pyplot as plt import torchvision.transforms as transforms import torchvision.models as models import copy use_cuda=torch.cuda.is_available() dtype=torch.cuda.FloatTensor if use_cuda else torch.FloatTensor style='images/timg.jpg' content='images/123.jpg' style_weight=1000 content_weight=1 imsize=128 loader=transforms.Compose([ transforms.Resize(imsize), transforms.ToTensor() ]) def image_loader(image_name): image=Image.open(image_name) image=Variable(loader(image)) image=image.unsqueeze(0) return image style_img=image_loader(style).type(dtype) content_img=image_loader(content).type(dtype) print(style_img) assert style_img.size()==content_img.size() def imshow(tensor,title=None): image=tensor.clone().cpu() image=image.view(3,imsize,imsize) image=unloader(image) plt.imshow(image) if title is not None: plt.title(title) plt.pause(0.001) unloader=transforms.ToPILImage() # plt.ion() # # plt.figure() # imshow(style_img.data,title='Style Image') # # plt.figure() # imshow(content_img.data,title='Content Image') # 加载网络 cnn=models.vgg19(pretrained=True).features if use_cuda: cnn=cnn.cuda() class ContentLoss(nn.Module): def __init__(self,target,weight): super(ContentLoss,self).__init__() self.target=target.detach()*weight self.weight=weight self.criterion=nn.MSELoss() def forward(self, *input): self.loss=self.criterion(input*self.weight,self.target) self.output=input return self.output def backward(self,retain_graph=True): self.loss.backward(retain_graph=retain_graph) return self.loss class StyleLoss(nn.Module): def __init__(self,target,weight): super(StyleLoss,self).__init__() self.target=target.detach()*weight self.weight=weight #self.gram=GramMatrix() self.criterion=nn.MSELoss() def forward(self,input): self.output=input.clone() input=input.cuda() self_G=Gram(input) self_G.mul(self.weight) self.loss=self.criterion(self_G,self.target) return self.output def backward(self,retain_graph=True): self.loss.backward(retain_graph=retain_graph) return self.loss def Gram(input): a,b,c,d=input.size() features=input.view(a*b,c*d) G=torch.mm(features,features.t()) return G.div(a*b*c*d) content_layers=['conv_4'] style_layers=['conv_1','conv_2','conv_3','conv_4','conv_5'] content_losses=[] style_losses=[] model=nn.Sequential() if use_cuda: model=model.cuda() i=1 for layer in list(cnn): if isinstance(layer,nn.Conv2d): name='conv_'+str(i) model.add_module(name,layer) if name in content_layers: target=model(content_img).clone() content_loss=ContentLoss(target,content_weight) content_loss=content_loss.cuda() if use_cuda else content_loss model.add_module('content_loss'+str(i),content_loss) content_losses.append(content_loss) if name in style_layers: target_feature=model(style_img).clone() target_feature=target_feature.cuda() if use_cuda else target_feature target_feature_gram=Gram(target_feature) style_loss=StyleLoss(target_feature_gram,style_weight) style_loss=style_loss.cuda() if use_cuda else style_loss model.add_module("style_loss"+str(i),style_loss) style_losses.append(style_loss) if isinstance(layer,nn.ReLU): name='relu'+str(i) model.add_module(name,layer) i+=1 if isinstance(layer,nn.MaxPool2d): name="pool"+str(i) model.add_module(name,layer) input_img=Variable(torch.randn(content_img.data.size())) if use_cuda: input_img=input_img.cuda() content_img=content_img.cuda() style_img=style_img.cuda() plt.figure() imshow(input_img.data,title='Input Image')
Experiment "X": Explosions Expected 代码程序
Description Unlucky scientist Vasya was tired of permanent mockeries of his colleagues. He built a time machine to go away into the future. But his machine had taken him into the past and then exploded! Vasya needed some way to earn money! He has taken the job of the Court Alchemist of King Arthur. His first task is to create the philosophers' stone. Vasya has found K ingredients and now conducts experiments which consist in mixing these ingredients in various proportions. More formally, each experiment consists in taking a1 ounces of the first ingredient, a2 ounces of the second and so on. Then all the ingredients are put into the crucible, carefully mixed and heated. All ai are non-negative integers, and their sum does not exceed S -- the capacity of the crucible. In all Vasya's experiments at least two ingredients are taken, i.e. there are at least two ai greater than zero. But all his experiments have been unsuccessful up to now. All mixtures have exploded! The King is unpleased. Maids of honour complain to Queen Guinevere about these awful explosion sounds! The King has decided to give one last chance to Vasya. Tomorrow Vasya is to conduct his next experiment, which could become the last. If the mixture explodes again, Vasya will be executed. Fortunately, Vasya has just found way to discard some definitely unsuccessful experiments. He has noted that if for some experiment plan (a1,a2,...,aK) the mixture has exploded, it would explode for any plan (b1,b2,...,bK) such that bi >= ai for all i. Now Vasya wants to count the number of possible experiments which are not definitely unsuccessful according to his unfortunate experience. He has taken out his pocket computer and now he is writing a program which will compute this number. Can you do this? Input The first line of input file contains three positive integers 2<=K<= 30, 2<=S<=10000, 0<= M <=20 where M is the number of experiments Vasya has already conducted. The next M lines contain K numbers each, one line per experiment. Output Output the number of possible experiment plans for which it is not evident that the mixture would explode. Sample Input 2 4 2 1 3 2 1 Sample Output 2
Sky Soldiers 输出计算
Problem Description An airplane carried k soldiers with parachute is plan to let these soldiers jump off the plane along a straight air route. The landing point of these soldiers is undetermined because of various weather conditions. However, the statisticians of the army can analysis the probability of landing in a certain place through landing history records. To make it simple, the statistician suggests that these sky soldiers will land on finite discrete points of a straight line. This mission plans to place m provisions for the soldiers on the line for landing. These soldiers will be informed the direction of the nearest provision point by a special device after landing, and then walk to the point. The manager of this mission is asking you for help: to determine m points for provisions so that the expected sum of walking distance should be minimized. You can put provisions on any point of the landing line. Input There are multiple test cases. For each case, the first line contains two integers k and m (1 ≤ k ≤ 1,000, 1 ≤ m ≤ 50), which represent the number of sky soldiers and the number of positions to place provisions separately. The following k lines contain descriptions of landing parameters for the soldiers numbered from 1 to k. Each description consists of an integer L followed by L pairs of (x, p), which indicates that the probability of the soldier's landing on integer coordination x is p. It is guaranteed that all the p values are positive real numbers, and the sum of p in a single line is exactly 1. The same x may appear more than once on the same line which you should simply add up all the probability p of the pairs with equal x. The number of places on which all the soldiers could land is no more than 1000 and it can not be less than m. The input ends with k=m=0. Output For each test case, output a line containing only one real number which indicates the minimum expected sum of distance these soldiers will move and should be rounded to two digits after the decimal point. Sample Input 2 1 2 0 0.5 1 0.5 2 1 0.1 3 0.9 0 0 Sample Output 2.30
Hunters 的程序的设计
Problem Description Alice and Bob are the topmost hunters in the forest, so no preys can escape from them. However, they both think that its hunting skill is better than the other. So they need a match. In their match, the targets are two animals, a tiger and a wolf. They both know that the tiger is living in the south of the forest and the wolf is living in the north of the forest. They decide that the one who kills the tiger scores X points and who kills the wolf scores Y points. If the one who kills both tiger and wolf scores X+Y points. Before the match starts, Alice is in the east of the forest and Bob is in the west of the forest. When the match starts, Alice and Bob will choose one of the preys as targets. Because they haven't known the other's choice, maybe they choose the same target. There will be two situations: (1) If they choose different targets, they both are sure of killing their respective targets. (2) If they choose the same target, the probability of Alice killing the target is P, and the probability of Bob killing it is 1-P. Then they will hunt for the other prey, also the probability of Alice killing it is P and the probability of Bob killing it is 1-P. But Alice knows about Bob. She knows that the probability of Bob choosing tiger as his first target is Q, and the probability of choosing wolf is 1-Q. So that Alice can decide her first target to make her expected score as high as possible. Input The first line of input contains an integer T (1≤T≤10000), the number of test cases. Then T test cases follow. Each test case contains X, Y, P, Q in one line. X and Y are integers and 1≤X, Y≤1000000000. P and Q are decimals and 0≤P, Q≤1, and there are at most two digits after decimal point. Output For each test case, output the target Alice should choose and the highest expected score she can get, in one line, separated by a space. The expected score should be rounded to the fourth digit after decimal point. It is guaranteed that Alice will have different expected score between choosing tiger and wolf. Sample Input 3 2 1 0.5 0.5 2 1 0 1 7 7 0.32 0.16 Sample Output tiger 1.7500 wolf 1.0000 tiger 6.5968
cannot compute MatMul as input #0 was expected to be a double tensor but is a float tensor [Op:MatMul] name: MatMul/
cannot compute MatMul as input #0 was expected to be a double tensor but is a float tensor [Op:MatMul] name: MatMul/ 是什么错误哇,谢谢大佬们
Break the Chocolate 的问题
Problem Description Benjamin is going to host a party for his big promotion coming up. Every party needs candies, chocolates and beer, and of course Benjamin has prepared some of those. But as everyone likes to party, many more people showed up than he expected. The good news is that candies are enough. And for the beer, he only needs to buy some extra cups. The only problem is the chocolate. As Benjamin is only a 'small court officer' with poor salary even after his promotion, he can not afford to buy extra chocolate. So he decides to break the chocolate cubes into smaller pieces so that everyone can have some. He have two methods to break the chocolate. He can pick one piece of chocolate and break it into two pieces with bare hand, or put some pieces of chocolate together on the table and cut them with a knife at one time. You can assume that the knife is long enough to cut as many pieces of chocolate as he want. The party is coming really soon and breaking the chocolate is not an easy job. He wants to know what is the minimum number of steps to break the chocolate into unit-size pieces (cubes of size 1 × 1 × 1). He is not sure whether he can find a knife or not, so he wants to know the answer for both situations. Input The first line contains an integer T(1<= T <=10000), indicating the number of test cases. Each test case contains one line with three integers N,M,K(1 <=N,M,K <=2000), meaning the chocolate is a cube of size N ×M × K. Output For each test case in the input, print one line: "Case #X: A B", where X is the test case number (starting with 1) , A and B are the minimum numbers of steps to break the chocolate into N × M × K unit-size pieces with bare hands and knife respectively. Sample Input 2 1 1 3 2 2 2 Sample Output Case #1: 2 2 Case #2: 7 3
130 个相见恨晚的超实用网站,一次性分享出来
相见恨晚的超实用网站 持续更新中。。。
我花了一夜用数据结构给女朋友写个H5走迷宫游戏
起因 又到深夜了,我按照以往在csdn和公众号写着数据结构!这占用了我大量的时间!我的超越妹妹严重缺乏陪伴而 怨气满满! 而女朋友时常埋怨,认为数据结构这么抽象难懂的东西没啥作用,常会问道:天天写这玩意,有啥作用。而我答道:能干事情多了,比如写个迷宫小游戏啥的! 当我码完字准备睡觉时:写不好别睡觉! 分析 如果用数据结构与算法造出东西来呢? ...
字节跳动视频编解码面经
三四月份投了字节跳动的实习(图形图像岗位),然后hr打电话过来问了一下会不会opengl,c++,shador,当时只会一点c++,其他两个都不会,也就直接被拒了。 七月初内推了字节跳动的提前批,因为内推没有具体的岗位,hr又打电话问要不要考虑一下图形图像岗,我说实习投过这个岗位不合适,不会opengl和shador,然后hr就说秋招更看重基础。我当时想着能进去就不错了,管他哪个岗呢,就同意了面试...
win10系统安装教程(U盘PE+UEFI安装)
一、准备工作 u盘,电脑一台,win10原版镜像(msdn官网) 二、下载wepe工具箱 极力推荐微pe(微pe官方下载) 下载64位的win10 pe,使用工具箱制作启动U盘打开软件, 选择安装到U盘(按照操作无需更改) 三、重启进入pe系统 1、关机后,将U盘插入电脑 2、按下电源后,按住F12进入启动项选择(技嘉主板是F12) 选择需要启...
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
《奇巧淫技》系列-python!!每天早上八点自动发送天气预报邮件到QQ邮箱
将代码部署服务器,每日早上定时获取到天气数据,并发送到邮箱。 也可以说是一个小人工智障。 思路可以运用在不同地方,主要介绍的是思路。
致 Python 初学者
欢迎来到“Python进阶”专栏!来到这里的每一位同学,应该大致上学习了很多 Python 的基础知识,正在努力成长的过程中。在此期间,一定遇到了很多的困惑,对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 python 这门编程语言,从2009年开始单一使用 python 应对所有的开发工作,直至今天。回顾自己的学习过程,也曾经遇到过无数的困难,也曾经迷茫过、困惑过。开办这个专栏,正是为了帮助像我当年一样困惑的 Python 初学者走出困境、快速成长。希望我的经验能真正帮到你
Linux(服务器编程):15---两种高效的事件处理模式(reactor模式、proactor模式)
前言 同步I/O模型通常用于实现Reactor模式 异步I/O模型则用于实现Proactor模式 最后我们会使用同步I/O方式模拟出Proactor模式 一、Reactor模式 Reactor模式特点 它要求主线程(I/O处理单元)只负责监听文件描述符上是否有事件发生,有的话就立即将时间通知工作线程(逻辑单元)。除此之外,主线程不做任何其他实质性的工作 读写数据,接受新的连接,以及处...
HAL 硬件抽象层介绍
和你一起终身学习,这里是程序员Android本篇文章主要介绍Android开发中的部分知识点,通过阅读本篇文章,您将收获以下内容:和你一起终身学习,这里是程序员 Android本篇文章主要介绍Android开发中的部分知识点,通过阅读本篇文章,您将收获以下内容:一、HAL 概述一、HAL 概述HAL定义了供硬件供应商实施的标准接口,该接口使Android无需考虑底层驱动程序的实现。使用HA...
加快推动区块链技术和产业创新发展,2019可信区块链峰会在京召开
11月8日,由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办,科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。   区块链技术被认为是继蒸汽机、电力、互联网之后,下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力,电力解决了人类基本的生活需求,互联网彻底改变了信息传递的方式,区块链作为构造信任的技术有重要的价值。   1...
8年经验面试官详解 Java 面试秘诀
作者 |胡书敏 责编 | 刘静 出品 | CSDN(ID:CSDNnews) 本人目前在一家知名外企担任架构师,而且最近八年来,在多家外企和互联网公司担任Java技术面试官,前后累计面试了有两三百位候选人。在本文里,就将结合本人的面试经验,针对Java初学者、Java初级开发和Java开发,给出若干准备简历和准备面试的建议。 Java程序员准备和投递简历的实...
知乎高赞:中国有什么拿得出手的开源软件产品?(整理自本人原创回答)
知乎高赞:中国有什么拿得出手的开源软件产品? 在知乎上,有个问题问“中国有什么拿得出手的开源软件产品(在 GitHub 等社区受欢迎度较好的)?” 事实上,还不少呢~ 本人于2019.7.6进行了较为全面的回答,对这些受欢迎的 Github 开源项目分类整理如下: 分布式计算、云平台相关工具类 1.SkyWalking,作者吴晟、刘浩杨 等等 仓库地址: apache/skywalking 更...
致 Python 初学者们!
作者| 许向武 责编 | 屠敏 出品 | CSDN 博客 前言 在 Python 进阶的过程中,相信很多同学应该大致上学习了很多 Python 的基础知识,也正在努力成长。在此期间,一定遇到了很多的困惑,对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 Python 这门编程语言,从2009年开始单一使用 Python 应对所有的开发工作,直至今...
究竟你适不适合买Mac?
我清晰的记得,刚买的macbook pro回到家,开机后第一件事情,就是上了淘宝网,花了500元钱,找了一个上门维修电脑的师傅,上门给我装了一个windows系统。。。。。。 表砍我。。。 当时买mac的初衷,只是想要个固态硬盘的笔记本,用来运行一些复杂的扑克软件。而看了当时所有的SSD笔记本后,最终决定,还是买个好(xiong)看(da)的。 已经有好几个朋友问我mba怎么样了,所以今天尽量客观...
使用 Angular 打造微前端架构的 ToB 企业级应用
这篇文章其实已经准备了11个月了,因为虽然我们年初就开始使用 Angular 的微前端架构,但是产品一直没有正式发布,无法通过生产环境实践验证可行性,11月16日我们的产品正式灰度发布,所以是时候分享一下我们在使用 Angular 微前端这条路上的心得(踩过的坑)了额,希望和 Angular 社区一起成长一起进步,如果你对微前端有一定的了解并且已经在项目中尝试了可以忽略前面的章节。 什么是微前...
大学四年因为知道了这32个网站,我成了别人眼中的大神!
依稀记得,毕业那天,我们导员发给我毕业证的时候对我说“你可是咱们系的风云人物啊”,哎呀,别提当时多开心啦????,嗯,我们导员是所有导员中最帅的一个,真的???? 不过,导员说的是实话,很多人都叫我大神的,为啥,因为我知道这32个网站啊,你说强不强????,这次是绝对的干货,看好啦,走起来! PS:每个网站都是学计算机混互联网必须知道的,真的牛杯,我就不过多介绍了,大家自行探索,觉得没用的,尽管留言吐槽吧???? 社...
拿下微软、Google、Adobe,印度为何盛产科技圈 CEO?
作者 | 胡巍巍 出品 | CSDN(ID:CSDNnews) 世界500强中,30%的掌舵人,都是印度人。 是的,你没看错。这是近日《哈佛商业评论》的研究结果。 其中又以微软CEO萨提亚·纳德拉(Satya Nadella)、和谷歌CEO桑达尔·皮查伊(Sundar Pichai,以下简称劈柴)最为出名。 微软CEO萨提亚·纳德拉(Satya Nadella) 其他著名印度...
Linux(内核剖析):19---中断总体概述
一、为什么要引入中断? 任何操作系统内核的核心任务,都包含有对连接到计算机上的硬件设备进行有效管理,如硬盘、蓝光碟机、键盘、鼠标、3D 处理器,以及无线电等。而想要管理这些设备,首先要能和它们互通音信才行。众所周知,处理器的速度跟外围硬件设备的速度往往不在一个数量级上,因此,如果内核采取让处理器向硬件发出一个请求,然后专门等待回应的办法,显然差强人意。既然硬件的响应这么慢,那么内核就应该在此期间...
程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
Java工作4年来应聘要16K最后没要,细节如下。。。
前奏: 今天2B哥和大家分享一位前几天面试的一位应聘者,工作4年26岁,统招本科。 以下就是他的简历和面试情况。 基本情况: 专业技能: 1、&nbsp;熟悉Sping了解SpringMVC、SpringBoot、Mybatis等框架、了解SpringCloud微服务 2、&nbsp;熟悉常用项目管理工具:SVN、GIT、MAVEN、Jenkins 3、&nbsp;熟悉Nginx、tomca...
深度学习笔记------卷积神经网络
深度学习笔记------卷积神经网络
一文带你入门Linux
文章目录1.1 Linux的概述:1.1.1 什么是Linux:1.1.1.1 学习Linux之前先了解Unix1.1.1.2 Linux的概述:1.1.1.3 Linux的历史:1.1.1.4 Linux系统的应用:1.1.1.5 Linux的版本1.1.1.6 Linux的主流版本1.2 Linux的安装:1.2.1 虚拟机安装:1.2.1.1 什么是虚拟机1.2.1.2 安装VmWare1....
普通三本毕业,我怎么一路艰辛进入阿里的
英雄不问出处? 自古以来就有这样一句话,真的英雄不问出处吗?这句话太挫了。普通三本院校的我,大四的时候居然都不知道什么是校招,所以出处太重要了。这也是没有机会参加阿里校招的原因,毕竟校招门槛比社招还是要低的,最重要的是校招进入阿里能让你的起点比别人更高。 有幸可以社招进入阿里,了解了校招的思路,赶紧介绍给学弟们,现在我们三本院校的小学弟今年居然有 3 个人通过了阿里的校招。下面我也把这份宝贵的经...
作为一个程序员,CPU的这些硬核知识你必须会!
CPU对每个程序员来说,是个既熟悉又陌生的东西? 如果你只知道CPU是中央处理器的话,那可能对你并没有什么用,那么作为程序员的我们,必须要搞懂的就是CPU这家伙是如何运行的,尤其要搞懂它里面的寄存器是怎么一回事,因为这将让你从底层明白程序的运行机制。 随我一起,来好好认识下CPU这货吧 把CPU掰开来看 对于CPU来说,我们首先就要搞明白它是怎么回事,也就是它的内部构造,当然,CPU那么牛的一个东...
破14亿,Python分析我国存在哪些人口危机!
一、背景 二、爬取数据 三、数据分析 1、总人口 2、男女人口比例 3、人口城镇化 4、人口增长率 5、人口老化(抚养比) 6、各省人口 7、世界人口 四、遇到的问题 遇到的问题 1、数据分页,需要获取从1949-2018年数据,观察到有近20年参数:LAST20,由此推测获取近70年的参数可设置为:LAST70 2、2019年数据没有放上去,可以手动添加上去 3、将数据进行 行列转换 4、列名...
强烈推荐10本程序员在家读的书
很遗憾,这个春节注定是刻骨铭心的,新型冠状病毒让每个人的神经都是紧绷的。那些处在武汉的白衣天使们,尤其值得我们的尊敬。而我们这些窝在家里的程序员,能不外出就不外出,就是对社会做出的最大的贡献。 有些读者私下问我,窝了几天,有点颓丧,能否推荐几本书在家里看看。我花了一天的时间,挑选了 10 本我最喜欢的书,你可以挑选感兴趣的来读一读。读书不仅可以平复恐惧的压力,还可以对未来充满希望,毕竟苦难终将会...
Python实战:抓肺炎疫情实时数据,画2019-nCoV疫情地图
今天,群里白垩老师问如何用python画武汉肺炎疫情地图。白垩老师是研究海洋生态与地球生物的学者,国家重点实验室成员,于不惑之年学习python,实为我等学习楷模。先前我并没有关注武汉肺炎的具体数据,也没有画过类似的数据分布图。于是就拿了两个小时,专门研究了一下,遂成此文。
疫情数据接口api
返回json示例 { "errcode":0,//0标识接口正常 "data":{ "date":"2020-01-30 07:47:23",//实时更新时间 "diagnosed":7736,//确诊人数 "suspect":12167,//疑是病例人数 "death":170,//死亡人数 "cur...
智力题(程序员面试经典)
NO.1  有20瓶药丸,其中19瓶装有1克/粒的药丸,余下一瓶装有1.1克/粒的药丸。给你一台称重精准的天平,怎么找出比较重的那瓶药丸?天平只能用一次。 解法 有时候,严格的限制条件有可能反倒是解题的线索。在这个问题中,限制条件是天平只能用一次。 因为天平只能用一次,我们也得以知道一个有趣的事实:一次必须同时称很多药丸,其实更准确地说,是必须从19瓶拿出药丸进行称重。否则,如果跳过两瓶或更多瓶药...
疫情防控,开发者集结出战!
作者 | 屠敏出品 | CSDN(ID:CSDNnews)2020 年伊始,病毒肆虐,人心惶惶。截止北京时间 1 月 31 日 15 时 30 分,全国确诊新型冠状病毒肺炎的数字已达到了...
如果孔子是个程序员,一定是P14
点击“技术领导力”关注∆每天早上8:30推送 作者|Mr.K 编辑| Emma 近日,研读《史记》,读到孔子跟师襄子学弹琴这一段,颇受启发,整理出来与大家分享,故事讲述了孔子如何学习弹琴,达到登峰造极的地步。仔细想想,其修炼方法,放在学习编程上,乃至学习任何一门技能上,都是相通的。 01 孔子年轻的时候,对音乐产生了极大的兴趣,找到了当时弹琴弹得最牛的师襄子,要拜师学艺,孔子比...
相关热词 c# 压缩图片好麻烦 c#计算数组中的平均值 c#获取路由参数 c#日期精确到分钟 c#自定义异常必须继承 c#查表并返回值 c# 动态 表达式树 c# 监控方法耗时 c# listbox c#chart显示滚动条
立即提问

相似问题

6
Java json字符串转jsonobject报错????
0
keras.util.sequence + fit_generator 如何实现多输出model
1
ord(‘中’)出错代码如下
4
python调用cv2.findContours时报错:ValueError: not enough values to unpack (expected 3, got 2)
0
Expected 2D array, got 1D array instead: array=[1]
2
清翔51 AT89C52 c(82): error C141: syntax error near '', expected '__asm' 网上查不到,求大佬帮助
2
请问:error: expected primary-expression before '[' token 该怎么解决?
0
Input 0 is incompatible with layer lstm_15: expected ndim=3, found ndim=4
1
TensorFlow的Keras如何使用Dataset作为数据输入?
3
分页方法Wrong number of parameters: expected 0, was given 2 Query
1
TypeError: expected str, bytes or os.PathLike object, not tuple此报错有大神遇到过吗怎么解决
1
Keras做序列到序列任务,出现这样的低级错误该怎么解决?
2
[Error] expected ')' before ';' token这个错误一直消不掉,第一次提问,没有悬赏真抱歉了,谢谢大哥们了
1
mui ios 报错,安卓正常
3
Spring Boot启动报错ERROR 3644 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
1
angular项目引用ng-zorro-antd运行时报错
5
springboot项目集成通用Mapper接口报错
1
tensorflow代码用CPU运行时没有错误,用GPU运行时每次到51%报错,网上没有搜到相同的问题
1
代码用tensorflow-CPU运行时没有错误,用GPU运行时每次到51%报错
0
C语言是怎么才能实现的,集体的代码