int main(){ int t; scanf("%d",&t); while(t--){ L n,N; scanf("%lld",&N); //N=scanInt(); printf("%ld\n",luc(N)); } return 0; }
int main(){ int t; scanf("%d",&t); while(t--){ L n,N; scanf("%lld",&N); n=N+5; //N=scanInt(); //printf("%ld\n",luc(N)); L ans=Mod((Mod(n*luc(n))-fib(n))/5); ans=Mod(ans-2*fib(n-1)); ans=Mod(ans-2*fib(n-2)); ans=Mod(ans-3*fib(n-3)); ans=Mod(ans+2*fib(N)); printf("%ld\n",ans); //printf("%ld\n",Mod(Mod((Mod(n)*luc(n)-fib(n))/5)-2*fib(n-1)-2*fib(n-2)-Mod(3*fib(n-3)+2*fib(N)))); } return 0; }
int main(){ int t; scanf("%d",&t); while(t--){ L n,N; //N=scanInt(); scanf("%lld",&N); if(N==0||N==1) {puts("0");continue;} n=N+5; //N=scanInt(); //printf("%ld\n",luc(N)); L ans=(Mod(Mod(n)*luc(n))-fib(n)); ans=(ans*400000003)%MOD; //ans=Mod(ans-2*fib(n-1)); //ans=Mod(ans-2*fib(n-2)); //ans=Mod(ans-3*fib(n-3)); ans=Mod(ans+2*fib(N)-4*fib(N+4)-fib(N+2)); printf("%ld\n",ans); //printf("%ld\n",Mod(Mod((Mod(n)*luc(n)-fib(n))/5)-2*fib(n-1)-2*fib(n-2)-Mod(3*fib(n-3)+2*fib(N)))); } return 0; }
bool UNICOREClient::submit(const JobDescription& jobdesc, XMLNode& id, bool delegate) { std::string faultstring; logger.msg(INFO, "Creating and sending request"); // Create job request /* bes-factory:CreateActivity bes-factory:ActivityDocument jsdl:JobDefinition */ PayloadSOAP req(unicore_ns); XMLNode op = req.NewChild("bes-factory:CreateActivity"); XMLNode act_doc = op.NewChild("bes-factory:ActivityDocument"); set_bes_factory_action(req, "CreateActivity"); WSAHeader(req).To(rurl.str()); //XMLNode proxyHeader = req.Header().NewChild("u6:Proxy"); if (true) { std::string pem_str; std::ifstream proxy_file(proxyPath.c_str()/*, ifstream::in*/); std::getline<char>(proxy_file, pem_str, 0); req.Header().NewChild("u6:Proxy") = pem_str; //std::cout << "\n----\n" << "pem_str = " << pem_str << "\n----\n"; //debug code, remove! } //std::string jsdl_str; //std::getline<char>(jsdl_file, jsdl_str, 0); std::string jsdl_str; if (!jobdesc.UnParse(jsdl_str, "nordugrid:jsdl")) { logger.msg(INFO, "Unable to submit job. Job description is not valid in the %s format", "nordugrid:jsdl"); return false; } XMLNode jsdl_doc = act_doc.NewChild(XMLNode(jsdl_str)); //std::cout << "\n----\n" << jsdl_str << "\n----\n"; //Debug line to verify the activity document jsdl_doc.Namespaces(unicore_ns); // Unify namespaces PayloadSOAP *resp = NULL; XMLNode ds = act_doc["jsdl:JobDefinition"]["jsdl:JobDescription"]["jsdl:DataStaging"]; for (; (bool)ds; ds = ds[1]) { // FilesystemName - ignore // CreationFlag - ignore // DeleteOnTermination - ignore XMLNode source = ds["jsdl:Source"]; XMLNode target = ds["jsdl:Target"]; if ((bool)source) { std::string s_name = ds["jsdl:FileName"]; if (!s_name.empty()) { XMLNode x_url = source["jsdl:URI"]; std::string s_url = x_url; if (s_url.empty()) s_url = "./" + s_name; else { URL u_url(s_url); if (!u_url) { if (s_url[0] != '/') s_url = "./" + s_url; } else { if (u_url.Protocol() == "file") { s_url = u_url.Path(); if (s_url[0] != '/') s_url = "./" + s_url; } else s_url.resize(0); } } if (!s_url.empty()) x_url.Destroy(); } } } act_doc.GetXML(jsdl_str); logger.msg(DEBUG, "Job description to be sent: %s", jsdl_str); // Try to figure out which credentials are used // TODO: Method used is unstable beacuse it assumes some predefined // structure of configuration file. Maybe there should be some // special methods of ClientTCP class introduced. std::string deleg_cert; std::string deleg_key; if (delegate) { client->Load(); // Make sure chain is ready XMLNode tls_cfg = find_xml_node((client->GetConfig())["Chain"], "Component", "name", "tls.client"); if (tls_cfg) { deleg_cert = (std::string)(tls_cfg["ProxyPath"]); if (deleg_cert.empty()) { deleg_cert = (std::string)(tls_cfg["CertificatePath"]); deleg_key = (std::string)(tls_cfg["KeyPath"]); } else deleg_key = deleg_cert; } if (deleg_cert.empty() || deleg_key.empty()) { logger.msg(ERROR, "Failed to find delegation credentials in " "client configuration"); return false; } } // Send job request + delegation if (client) { if (delegate) { DelegationProviderSOAP deleg(deleg_cert, deleg_key); logger.msg(INFO, "Initiating delegation procedure"); if (!deleg.DelegateCredentialsInit(*(client->GetEntry()), &(client->GetContext()))) { logger.msg(ERROR, "Failed to initiate delegation"); return false; } deleg.DelegatedToken(op); } MCC_Status status = client->process("http://schemas.ggf.org/bes/2006/08/bes-factory/" "BESFactoryPortType/CreateActivity", &req, &resp); if (!status) { logger.msg(ERROR, "Submission request failed"); return false; } if (resp == NULL) { logger.msg(VERBOSE, "There was no SOAP response"); return false; } } else if (client_entry) { Message reqmsg; Message repmsg; MessageAttributes attributes_req; attributes_req.set("SOAP:ACTION", "http://schemas.ggf.org/bes/2006/08/" "bes-factory/BESFactoryPortType/CreateActivity"); MessageAttributes attributes_rep; MessageContext context; if (delegate) { DelegationProviderSOAP deleg(deleg_cert, deleg_key); logger.msg(INFO, "Initiating delegation procedure"); if (!deleg.DelegateCredentialsInit(*client_entry, &context)) { logger.msg(ERROR, "Failed to initiate delegation"); return false; } deleg.DelegatedToken(op); } reqmsg.Payload(&req); reqmsg.Attributes(&attributes_req); reqmsg.Context(&context); repmsg.Attributes(&attributes_rep); repmsg.Context(&context); MCC_Status status = client_entry->process(reqmsg, repmsg); if (!status) { logger.msg(ERROR, "Submission request failed"); return false; } logger.msg(INFO, "Submission request succeed"); if (repmsg.Payload() == NULL) { logger.msg(VERBOSE, "There was no response to a submission request"); return false; } try { resp = dynamic_cast<PayloadSOAP*>(repmsg.Payload()); } catch (std::exception&) {} if (resp == NULL) { logger.msg(ERROR, "A response to a submission request was not " "a SOAP message"); delete repmsg.Payload(); return false; } } else { logger.msg(ERROR, "There is no connection chain configured"); return false; } //XMLNode id; SOAPFault fs(*resp); if (!fs) { (*resp)["CreateActivityResponse"]["ActivityIdentifier"].New(id); //id.GetDoc(jobid); //std::cout << "\n---\nActivityIdentifier:\n" << (std::string)((*resp)["CreateActivityResponse"]["ActivityIdentifier"]) << "\n---\n";//debug code delete resp; UNICOREClient luc((std::string)id["Address"], client_config); //local unicore client //std::cout << "\n---\nid element containing (?) Job Address:\n" << (std::string)id << "\n---\n";//debug code return luc.uasStartJob(); //return true; } else { faultstring = fs.Reason(); std::string s; resp->GetXML(s); delete resp; logger.msg(DEBUG, "Submission returned failure: %s", s); logger.msg(ERROR, "Submission failed, service returned: %s", faultstring); return false; } }
ZZn powl(const ZZn& x,const Big& k) { return luc(2*x,k)/2; }